NNG_HTTP_SERVER_ADD_HANDLER(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… nng_http_server_add_handler β€” the 3http page from the NNG Reference Manual, bestie edition πŸŽ€

okay so picture this: you're deep in the NNG Reference Manual, section 3http, and you need to glue a handler onto a server. That's it. That's the whole vibe. Let's go ✨


🌸 NAME 🌸

nng_http_server_add_handler β€” add an HTTP server handler, no cap 🫢


✨ SYNOPSIS ✨

#include <nng/nng.h>
#include <nng/supplemental/http/http.h>

int nng_http_server_add_handler(nng_http_server *s, nng_http_handler *h);

πŸ’– DESCRIPTION πŸ’–

So nng_http_server_add_handler() literally just adds the handler h to the server instance s. Match made in heaven, honestly πŸ’…

But listen β€” if another handler is already added to the server that would conflict with handler h, then the operation will fail with NNG_EADDRINUSE. Like, the spot's taken, bestie, pick a different one 😭

Also important: if a handler is added to a server, and the server is subsequently deallocated, the handler and any of its resources will also be deallocated. They go down together. Ride or die. 🫢

And if you ever change your mind, handlers that are added to a server may be subsequently removed using the nng_http_server_del_handler() function. Cleanup queen behaviour πŸ‘‘


🌈 RETURN VALUES 🌈

This function returns 0 on success, and non-zero otherwise. Simple as that ✨


πŸ’€ ERRORS πŸ’€

  • NNG_EADDRINUSE β€” Handler conflicts with another handler. (the drama 😀)
  • NNG_ENOMEM β€” Insufficient free memory exists. (your RAM said no πŸͺ«)
  • NNG_ENOTSUP β€” HTTP not supported. (it's giving "wrong build" πŸ™ˆ)

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie β€” go forth and register those handlers πŸ’œ

mwah πŸ’‹ β€” this was the NNG Reference Manual, NNG_HTTP_...DD_HANDLER(3http), dated 2026-01-13. now go touch some grass (after you check your return values) 🌱✨

πŸ“¦ where this page comes from