From 8d89baa38766e8d9e889fef560d9af368441bccd Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 9 Jul 2020 19:30:36 -0400 Subject: Add events page stub --- events.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/events.c b/events.c index c891bff..9262225 100644 --- a/events.c +++ b/events.c @@ -22,5 +22,24 @@ #include "server.h" enum kcgi_err pageEvents(struct kreq *req) { - return httpFail(req, KHTTP_501); + if (!req->fieldmap[Network] || !req->fieldmap[Context]) { + return httpFail(req, KHTTP_404); + } + + enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); + if (req->method == KMETHOD_HEAD) return error; + + const char *network = req->fieldmap[Network]->parsed.s; + const char *context = req->fieldmap[Context]->parsed.s; + + struct khtmlreq html; + error = error + || khttp_body(req) + || khtml_open(&html, req, KHTML_PRETTY) + || htmlHead(&html, context) + || htmlNav(&html, network, context) + || htmlSearch(&html, network, context); + if (error) return error; + + return khtml_close(&html); } -- cgit 1.4.1