summary refs log tree commit diff
path: root/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'server.c')
-rw-r--r--server.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/server.c b/server.c
index 751d414..ac8fc4f 100644
--- a/server.c
+++ b/server.c
@@ -48,6 +48,11 @@ const struct kvalid Keys[KeysLen] = {
 bool pagePublic;
 int pageLimit = 100;
 
+static const char CSS[] = {
+#include "default.css.h"
+};
+static const char *Cache = "public, max-age=86400, immutable";
+
 static enum kcgi_err request(struct kreq *req) {
 	if (req->method != KMETHOD_HEAD && req->method != KMETHOD_GET) {
 		return httpFail(req, KHTTP_405);
@@ -57,7 +62,14 @@ static enum kcgi_err request(struct kreq *req) {
 		case Contexts: return pageContexts(req);
 		case Events:   return pageEvents(req);
 		case Search:   return pageSearch(req);
-		default:       return httpFail(req, KHTTP_404);
+		case Stylesheet: {
+			if (req->mime != KMIME_TEXT_CSS) return httpFail(req, KHTTP_404);
+			return httpHead(req, KHTTP_200, KMIME_TEXT_CSS)
+				|| khttp_head(req, kresps[KRESP_CACHE_CONTROL], "%s", Cache)
+				|| khttp_body(req)
+				|| khttp_write(req, CSS, sizeof(CSS));
+		}
+		default: return httpFail(req, KHTTP_404);
 	}
 }