AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::rest::nginx Namespace Reference

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

Detailed Description

nginx applications bridge (see ANCH_REST_APPLICATION ).

Typedef Documentation

◆ Factory

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).

Function Documentation

◆ application()

const anch_rest_application_t * anch::rest::nginx::application ( )
noexcept

Application operations for a factory

Template Parameters
Fthe factory
Returns
the operations
Here is the call graph for this function:

◆ create()

void * anch::rest::nginx::create ( Factory factory,
const char * config,
char * error,
std::size_t errorSize )
noexcept

Create application: call factory and validate API

Parameters
factorythe factory
configthe configuration
errorthe error buffer
errorSizethe error buffer size
Returns
the API, nullptr on error (message in error )
Here is the call graph for this function:

◆ destroy()

void anch::rest::nginx::destroy ( void * app)
noexcept

Destroy application

Parameters
appthe API
Here is the call graph for this function:

◆ handle()

int anch::rest::nginx::handle ( void * app,
const anch_rest_request_t * request,
const anch_rest_response_writer_t * writer )
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, ...).

Parameters
appthe API
requestthe request
writerthe response writer
Returns
0 when response is complete, -1 when it has been interrupted after its start
Here is the call graph for this function: