NNG_HTTP_HANDLER_SET_HOST(3http)
β¨ NNG_HTTP_HANDLER_SET_HOST β¨
okay bestie, welcome to the nng_http_handler_set_host page π
this one lives in the NNG Reference Manual and it's honestly such a little icon β short, sweet, and it does exactly one thing. let's get into it π
πΈ NAME πΈ
nng_http_handler_set_host β set the host for an HTTP handler π«Ά
β¨ SYNOPSIS β¨
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_handler_set_host(nng_http_handler *handler, const char *host);
π DESCRIPTION π
so the way that nng_http_handler_set_host() works is: it limits the scope of the handler π like, instead of the handler being out here matching everything, it only gets called when the specified host matches the value of the Host: HTTP header. no cap. that's the whole vibe check π₯
π§ Tip: this is literally how you build servers with multiple handlers for virtual hosting. main character energy fr fr.
the value of the host can include a colon and a port, and it should match exactly the value of the Host header that the client sent π
(canonicalization of the host name is performed though, so don't stress about that part π©·)
π Tip: since the server framework does not support listening on multiple ports, the port number can be elided. the matching test only considers the hostname or IP address, and ignores any trailing port number β
π¦ RETURN VALUES π¦
this function returns 0 on success, and non-zero otherwise π (yes that's the whole thing, she's simple and we love her)
π ERRORS π
NNG_ENOMEMβ not enough free memory to do the thing π« like there's just insufficient free memory to perform the operation.NNG_ENOTSUPβ no support for HTTP in the library π as in, this build of the library doesn't do HTTP at all.
π₯ SEE ALSO π₯
that's the whole page bestie, go forth and host virtually ππ
mwah π β this has been the NNG Reference Manual, NNG_HTTP_...R_SET_HOST(3http), dated 2026-01-13. see u in the next manpage πΈ
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms