Mercurial > sci
diff scid/http.c @ 29:695637f1d8a7
scid: first index page in javascript
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 04 Aug 2022 14:13:58 +0200 |
parents | dae2de19ca5d |
children | 081e1c258e64 |
line wrap: on
line diff
--- a/scid/http.c Thu Aug 04 06:09:54 2022 +0200 +++ b/scid/http.c Thu Aug 04 14:13:58 2022 +0200 @@ -34,11 +34,13 @@ #include "page-api-todo.h" #include "page-api-workers.h" #include "page-index.h" -#include "page.h" +#include "page-static.h" +#include "pageutil.h" enum page { PAGE_INDEX, /* Job results at index. */ PAGE_API, + PAGE_STATIC, PAGE_LAST /* Not used. */ }; @@ -61,17 +63,19 @@ if (strncmp(req->path, apis[i].prefix, strlen(apis[i].prefix)) == 0) return apis[i].handler(req); - page(req, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html", NULL); + pageutil_status(req, KHTTP_404); } static const char *pages[] = { [PAGE_INDEX] = "", - [PAGE_API] = "api" + [PAGE_API] = "api", + [PAGE_STATIC] = "static" }; static void (*handlers[])(struct kreq *req) = { [PAGE_INDEX] = page_index, - [PAGE_API] = dispatch_api + [PAGE_API] = dispatch_api, + [PAGE_STATIC] = page_static }; static void @@ -82,7 +86,7 @@ log_debug("http: accessing page '%s'", req->path); if (req->page == PAGE_LAST) - page(req, KHTTP_404, KMIME_TEXT_HTML, "pages/404.html", NULL); + pageutil_status(req, KHTTP_404); else handlers[req->page](req); }