#include <nng/nng.h> #include <nng/supplemental/http/http.h> int nng_http_handler_set_tree(nng_http_handler *handler); int nng_http_handler_set_tree_exclusive(nng_http_handler *handler);
nng_http_handler_set_tree - set HTTP handler to match trees
nng_http_handler_set_tree() function causes the handler to be matched if the request URI sent
by the client is a logical child of the path for handler, and no more specific
handler has been registered.
nng_http_handler_set_tree_exclusive() function is similar to
with the distinction that the handler will be considered to exclusively handle its request URI.
nng_http_server_set_tree(), it will not be possible to register additional
handlers in logical subdirectories of handler.
This is useful in cases when the handler would like to examine the entire path and possibly behave differently; for example a REST API that uses the rest of the path to pass additional parameters.
|These methods are useful when constructing API handlers where a single service address (path) supports dynamically generated children.|
|The non-exclusive form is also useful for providing a default handler to be generated when a more specific child does not exist. This can provide a better experience for users than the standard 404 error handling.|
This function returns 0 on success, and non-zero otherwise.
Insufficient free memory exists.
No support for HTTP in the library.