|
| NATS_EXTERN microError * | microRequest_AddHeader (microRequest *req, const char *key, const char *value) |
| | Adds a header to the underlying NATS request message. More...
|
| |
| NATS_EXTERN microError * | microRequest_DeleteHeader (microRequest *req, const char *key) |
| | Deletes a header from the underlying NATS request message. More...
|
| |
| NATS_EXTERN natsConnection * | microRequest_GetConnection (microRequest *req) |
| | Returns the connection associated with the request. More...
|
| |
| NATS_EXTERN const char * | microRequest_GetData (microRequest *req) |
| | Returns the data in the the request, as a byte array. More...
|
| |
| NATS_EXTERN int | microRequest_GetDataLength (microRequest *req) |
| | Returns the number of data bytes in the the request. More...
|
| |
| NATS_EXTERN void * | microRequest_GetEndpointState (microRequest *req) |
| | Returns the pointer to the user-provided endpoint state, if the request is associated with an endpoint. More...
|
| |
| NATS_EXTERN microError * | microRequest_GetHeaderKeys (microRequest *req, const char ***keys, int *count) |
| | Gets the list of all header keys in the NATS message underlying the request. More...
|
| |
| NATS_EXTERN microError * | microRequest_GetHeaderValue (microRequest *req, const char *key, const char **value) |
| | Get the header entry associated with key from the NATS message underlying the request. More...
|
| |
| NATS_EXTERN microError * | microRequest_GetHeaderValues (microRequest *req, const char *key, const char ***values, int *count) |
| | Get all header values associated with key from the NATS message underlying the request. More...
|
| |
| NATS_EXTERN natsMsg * | microRequest_GetMsg (microRequest *req) |
| | Get the NATS message underlying the request. More...
|
| |
| NATS_EXTERN const char * | microRequest_GetReply (microRequest *req) |
| | Returns the reply subject set in this message. More...
|
| |
| NATS_EXTERN microService * | microRequest_GetService (microRequest *req) |
| | Returns the pointer to the microservice associated with the request. More...
|
| |
| NATS_EXTERN void * | microRequest_GetServiceState (microRequest *req) |
| | Returns the pointer to the user-provided service state. More...
|
| |
| NATS_EXTERN const char * | microRequest_GetSubject (microRequest *req) |
| | Returns the subject of the request message. More...
|
| |
| NATS_EXTERN microError * | microRequest_Respond (microRequest *req, const char *data, size_t len) |
| | Respond to a request, on the same NATS connection. More...
|
| |
| NATS_EXTERN microError * | microRequest_RespondError (microRequest *req, microError *err) |
| | Respond to a request with a simple error. More...
|
| |
| NATS_EXTERN microError * | microRequest_RespondCustom (microRequest *req, microError *err, const char *data, size_t len) |
| | Respond to a message, with an OK or an error. More...
|
| |
| NATS_EXTERN microError * | microRequest_SetHeader (microRequest *req, const char *key, const char *value) |
| | Add value to the header associated with key in the NATS message underlying the request. More...
|
| |
If err is NULL, RespondErrorWithData is equivalent to Respond. If err is not NULL, the response will include the error in the response header, and err will be freed.
The following example illustrates idiomatic usage in a request handler. Since this handler handles its own error responses, the only error it might return would be a failure to send the response.
err = somefunc();
if (err != NULL) {
}
...
NATS_EXTERN microError * microRequest_RespondCustom(microRequest *req, microError *err, const char *data, size_t len)
Respond to a message, with an OK or an error.
Or, if the request handler has its own cleanup logic:
if (err = somefunc(), err != NULL)
goto CLEANUP;
...
CLEANUP:
if (err != NULL) {
}
return NULL;
- Parameters
-
| req | the request. |
| err | the error to include in the response header. If NULL, no error. |
| data | the response data. |
| len | the length of the response data. |
- Note
- Returns
- an error, if any.