chttpserver · Section 3
chttpsvr_router_register_streaming_handler
NAME
chttpsvr_router_register_streaming_handler - register a streaming handler on a sub-router
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpserver.h>
ccol_retval chttpsvr_router_register_streaming_handler(chttpsvr_router *router,
chttp_method method,
const char *pattern,
chttpsvr_handler_fn fn,
void *ctx);
DESCRIPTION
The same as chttpsvr_register_streaming_handler, except that the
route goes on a sub-router. The pattern rules of
chttpsvr_register_streaming_handler apply here too: pattern must
start with '/', a {name} segment must contain only [A-Za-z0-9_], and
the same {name} must not appear more than once. CHTTP_ANY works as
the method argument as well. The handler runs on the streaming pool
of the server, exactly like a handler registered with
chttpsvr_register_streaming_handler.
The function first checks that the server that owns router has not
been destroyed. That check also holds against a destroy running on
another thread at the same time: A call that races a chttpsvr_destroy
of the owning server returns ccol_invalid_args and touches no freed
memory.
RETURN VALUE
ccol_success on success.
ccol_invalid_args when router, pattern or fn is NULL; when method is
not one of the seven methods or CHTTP_ANY; when
pattern does not start with '/'; when pattern has two
consecutive slashes or a trailing slash; when a
{name} segment contains a character outside
[A-Za-z0-9_]; when the same {name} appears more than
once; or when the server that owns router has been
destroyed.
ccol_not_enough_memory when an allocation fails.
SEE ALSO
chttpsvr_register_streaming_handler(3), chttpsvr_subrouter(3)