diff options
Diffstat (limited to 'handler.c')
| -rw-r--r-- | handler.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -4,6 +4,7 @@ #include "slweb/http.h" #include "slweb/server.h" #include "slweb/wildcard_cmp.h" +#include <pthread.h> #include <errno.h> #include <stdbool.h> #include <stddef.h> @@ -49,7 +50,8 @@ static int on_write(const void *const buf, const size_t n, void *const user) } static int on_payload(const struct http_payload *const p, - struct http_response *const r, void *const user) + struct http_response *const r, struct http_future *const f, + void *const user) { struct client *const c = user; struct handler *const h = c->h; @@ -59,7 +61,7 @@ static int on_payload(const struct http_payload *const p, const struct elem *const e = &h->elem[i]; if (e->op == p->op && !wildcard_cmp(p->resource, e->url, true)) - return e->f(p, r, e->user); + return e->f(p, r, f, e->user); } fprintf(stderr, "Not found: %s\n", p->resource); @@ -72,6 +74,20 @@ static int on_payload(const struct http_payload *const p, return 0; } +static void *async_start(void *const user) +{ + /* TOOD: call user callback. */ + return NULL; +} + +static int on_async(const struct http_future *const f, void *const user) +{ + struct client *const c = user; + struct handler *const h = c->h; + + return server_async(h->server, f->f, f->user); +} + static int on_length(const unsigned long long len, const struct http_cookie *const c, struct http_response *const r, void *const user) @@ -107,6 +123,7 @@ static struct client *find_or_alloc_client(struct handler *const h, .read = on_read, .write = on_write, .payload = on_payload, + .async = on_async, .length = on_length, .user = ret, .tmpdir = h->cfg.tmpdir |
