wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
wired_srvrun_handler Struct Reference

The application's request responder: the callback and its opaque context, registered on the loop as a pair (wired_srvloop_set_handler takes the same pair). More...

#include <srvrun.h>

Data Fields

wired_srvloop_handler cb
 the response-body builder callback
void * ctx
 opaque context passed back to cb / http
wired_http_handler http
 status- and header-aware responder; when set it is used instead of cb (0 keeps cb)
wired_srvloop_on_body on_body
 streams each request body here before the responder runs (see wired_srvloop_on_body for the sequencing); 0 buffers the body whole into req->body, up to one request window

Detailed Description

The application's request responder: the callback and its opaque context, registered on the loop as a pair (wired_srvloop_set_handler takes the same pair).

Example, answering a redirect:

static int on_http(void* ctx, wired_http_exchange* x) {
static const u8 n[] = "location", v[] = "/new";
(void)ctx;
x->status = 302;
x->fields[0] = (wired_http_field){wired_span_of(n, sizeof n - 1),
wired_span_of(v, sizeof v - 1)};
x->field_count = 1;
return 0;
}
wired_srvrun_handler h = {0, 0, on_http, 0};
static wired_span wired_span_of(const u8 *p, usz n)
Make a read-only span over p[0..n).
Definition span.h:70
qpack_field wired_http_field
One response header field line: lowercase name and value views (RFC 9114 4.2).
Definition srvrun.h:166
One request/response exchange handed to a wired_http_handler.
Definition srvrun.h:183
u16 status
response status; 0 means 200 (first round only)
Definition srvrun.h:192
usz field_count
entries used in fields
Definition srvrun.h:198
wired_http_field fields[WIRED_HTTP_MAX_FIELDS]
extra response header fields, in order (first round only)
Definition srvrun.h:196
void * ctx
opaque context passed back to cb / http
Definition srvrun.h:236
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18

The documentation for this struct was generated from the following file: