nginx applications bridge (see ANCH_REST_APPLICATION ).
More...
Typedefs | |
| using | Factory = std::unique_ptr<anch::rest::Api>(*)(std::string_view config) |
Functions | |
| void * | create (Factory factory, const char *config, char *error, std::size_t errorSize) noexcept |
| void | destroy (void *app) noexcept |
| int | handle (void *app, const anch_rest_request_t *request, const anch_rest_response_writer_t *writer) noexcept |
| template<anch::rest::nginx::Factory F> | |
| const anch_rest_application_t * | application () noexcept |
nginx applications bridge (see ANCH_REST_APPLICATION ).
| using anch::rest::nginx::Factory = std::unique_ptr<anch::rest::Api>(*)(std::string_view config) |
Application factory: creates the API of an nginx application (once in each worker process). The configuration is the second anch_rest_app directive argument (empty when not set).
|
noexcept |
Application operations for a factory
| F | the factory |
|
noexcept |
Create application: call factory and validate API
| factory | the factory |
| config | the configuration |
| error | the error buffer |
| errorSize | the error buffer size |
nullptr on error (message in error )
|
noexcept |
Destroy application
| app | the API |
|
noexcept |
Handle request with API (see anch::rest::Api::handle ). Unknown methods are answered with 501 , errors with 500 .
The request body is read in stream (anch::cutils::CIStream on the module reader): it is read while nginx receives it. The response body is written in stream (anch::cutils::COStream on the module writer, blocks of writer->buffer_size bytes): the response is started when the first block is full, with chunked transfer encoding, or at the end of the body with its length when it fits in one block. An error raised before the start is answered with 500 , an error raised after interrupts the response.
The request outlives the response body writing: a body writer can read the request body (echo, ...).
| app | the API |
| request | the request |
| writer | the response writer |
0 when response is complete, -1 when it has been interrupted after its start