carbond.Operation¶
Handles HTTP requests for a specific method (e.g., “GET”) to a specific Endpoint
by assigning to a property on the endpoint that corresponds to that HTTP method (e.g. get
). This can be instantiated explicitly in the context of an Endpoint
or implicitly if just a handler method is provided. In the latter case, the operation object will be built and instantiated for you.
Instance Properties¶
- ¶
description string
Default undefined Description A brief description of what this operation does. This will be displayed in any generated documentation.
- ¶
endpoint Required Description xxx
- ¶
name string
(read-only)Description The operation name (i.e., HTTP method)
- ¶
parameters Object.<string, carbond.OperationParameter>
Default {}
Description Any parameters that are specific to this operation (as opposed to those defined on the parent endpoint)
- ¶
responses Object.<string, carbond.OperationResponse>
Default {}
Description Response definitions for this operation. These will be used for validation purposes as well as generated static documentation.
Methods¶
- ¶
getAllParameters Return type Object.<string, carbond.OperationParameter> Description Gets all parameters defined for this Operation
which includes all parameters inherited from this.endpoint
- ¶
getSanitizedURL Arguments - req (http.ClientRequest) – the current request
Returns the sanitized URL Return type string Description Returns a new URL with the query string portion removed
- ¶
handle Deprecated Arguments Throws HttpError
Return type Object | null | undefined Description Handles incoming requests, generating the appropriate response. Responses can be sent by the handler itself or this can be delegated to the service. If an object is returned, it will be serialized (and validated if configured to do so) and sent as the body of the response. If null
is returned, it will end the response. Ifundefined
is returned, it will be the responsibility of the handler to end the response. If the response status code is something other than204
, it should be set by the handler. Additionally, custom headers should be set on the response object before returning. To respond with an error (status code > 400), an instance ofHttpError
can be thrown.