Mercurial > sci
diff scid/http.c @ 26:7e10cace67a3
scid: add basic mustache support
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 02 Aug 2022 13:24:13 +0200 |
parents | 34cbbd215ef7 |
children | dae2de19ca5d |
line wrap: on
line diff
--- a/scid/http.c Mon Jul 25 21:22:13 2022 +0200 +++ b/scid/http.c Tue Aug 02 13:24:13 2022 +0200 @@ -32,9 +32,11 @@ #include "page-api-projects.h" #include "page-api-todo.h" #include "page-api-workers.h" +#include "page-index.h" #include "page.h" enum page { + PAGE_INDEX, /* Job results at index. */ PAGE_API, PAGE_LAST /* Not used. */ }; @@ -58,14 +60,16 @@ if (strncmp(req->path, apis[i].prefix, strlen(apis[i].prefix)) == 0) return apis[i].handler(req); - page(req, NULL, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html"); + page(req, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html", NULL); } static const char *pages[] = { + [PAGE_INDEX] = "", [PAGE_API] = "api" }; static void (*handlers[])(struct kreq *req) = { + [PAGE_INDEX] = page_index, [PAGE_API] = dispatch_api }; @@ -77,7 +81,7 @@ log_debug("http: accessing page '%s'", req->path); if (req->page == PAGE_LAST) - page(req, NULL, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html"); + page(req, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html", NULL); else handlers[req->page](req); }