summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--events.c21
1 files changed, 20 insertions, 1 deletions
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);
 }