summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-09 19:30:36 -0400
committerJune McEnroe <june@causal.agency>2020-07-09 19:30:36 -0400
commit8d89baa38766e8d9e889fef560d9af368441bccd (patch)
tree1c2228c6b10a8201bd5117f482225fa1e11236e1
parentAdd search forms (diff)
downloadscooper-8d89baa38766e8d9e889fef560d9af368441bccd.tar.gz
scooper-8d89baa38766e8d9e889fef560d9af368441bccd.zip
Add events page stub
-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);
 }