NNG_HTTP_HANDLER_SET_TREE(3http)

πŸ“¦ version 1.11, in alpine 3.24

✨ NAME ✨

nng_http_handler_set_tree β€” set HTTP handler to match trees. Welcome to the NNG Reference Manual, bestie; this is the NNG_HTTP_HANDLER_SET_TREE(3http) page, and yes we’re getting into tree-matching handler lore. πŸ’…


🌸 SYNOPSIS 🌸

#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);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so nng_http_handler_set_tree() makes the handler match when the request URI sent by the client is a logical child of the path for handler, and no more specific handler has been registered. That’s the whole vibe. ✨

nng_http_handler_set_tree_exclusive() is similar to nng_http_server_set_tree() β€” yes, that’s the exact name in this manual page, bestie β€” with the distinction that the handler will be considered to exclusively handle its request URI. Unlike nng_http_server_set_tree(), it will not be possible to register additional handlers in logical subdirectories of handler. Periodt. πŸ’€

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. Iconic. πŸ“

Tip: These methods are useful when constructing API handlers where a single service address (path) supports dynamically generated children. 🫢
Tip: 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. 🌈

πŸ’– RETURN VALUES πŸ’–

This function returns 0 on success, and non-zero otherwise. Slay. ✨

πŸŽ€ ERRORS πŸŽ€

  • NNG_ENOMEM β€” Insufficient free memory exists. 😭
  • NNG_ENOTSUP β€” No support for HTTP in the library. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


That’s the tea, bestie πŸ’– this page is from the NNG Reference Manual, dated 2026-01-13, with the footer vibe NNG_HTTP_...R_SET_TREE(3http). Go off. πŸ’…

πŸ“¦ where this page comes from