Mercurial > sci
comparison scid/http.c @ 47:e8f24896b484
scid: add /workers page
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 16 Aug 2022 18:29:08 +0200 |
parents | 576f4b1ec79f |
children | b474f0985e39 |
comparison
equal
deleted
inserted
replaced
46:16f1c72d1635 | 47:e8f24896b484 |
---|---|
34 #include "page-api-todo.h" | 34 #include "page-api-todo.h" |
35 #include "page-api-workers.h" | 35 #include "page-api-workers.h" |
36 #include "page-index.h" | 36 #include "page-index.h" |
37 #include "page-jobresults.h" | 37 #include "page-jobresults.h" |
38 #include "page-static.h" | 38 #include "page-static.h" |
39 #include "page-workers.h" | |
39 #include "pageutil.h" | 40 #include "pageutil.h" |
40 #include "scid.h" | 41 #include "scid.h" |
41 | 42 |
42 enum page { | 43 enum page { |
43 PAGE_INDEX, /* Job results at index. */ | 44 PAGE_INDEX, /* Job results at index. */ |
45 PAGE_API, /* JSON API with key authentication. */ | |
44 PAGE_JOBRESULTS, /* List of jobresult for one job. */ | 46 PAGE_JOBRESULTS, /* List of jobresult for one job. */ |
45 PAGE_API, | 47 PAGE_STATIC, /* Static files delivery. */ |
46 PAGE_STATIC, | 48 PAGE_WORKERS, /* User view of workers. */ |
47 PAGE_LAST /* Not used. */ | 49 PAGE_LAST /* Not used. */ |
48 }; | 50 }; |
49 | 51 |
50 static int | 52 static int |
51 allowed(const struct kreq *req) | 53 allowed(const struct kreq *req) |
84 | 86 |
85 pageutil_status(req, KHTTP_404); | 87 pageutil_status(req, KHTTP_404); |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 static const char *pages[] = { | 91 static const char * const pages[] = { |
90 [PAGE_INDEX] = "", | 92 [PAGE_INDEX] = "", |
93 [PAGE_API] = "api", | |
91 [PAGE_JOBRESULTS] = "jobresults", | 94 [PAGE_JOBRESULTS] = "jobresults", |
92 [PAGE_API] = "api", | 95 [PAGE_STATIC] = "static", |
93 [PAGE_STATIC] = "static" | 96 [PAGE_WORKERS] = "workers" |
94 }; | 97 }; |
95 | 98 |
96 static void (*handlers[])(struct kreq *req) = { | 99 static void (*handlers[])(struct kreq *req) = { |
97 [PAGE_INDEX] = page_index, | 100 [PAGE_INDEX] = page_index, |
101 [PAGE_API] = dispatch_api, | |
98 [PAGE_JOBRESULTS] = page_jobresults, | 102 [PAGE_JOBRESULTS] = page_jobresults, |
99 [PAGE_API] = dispatch_api, | 103 [PAGE_STATIC] = page_static, |
100 [PAGE_STATIC] = page_static | 104 [PAGE_WORKERS] = page_workers |
101 }; | 105 }; |
102 | 106 |
103 static void | 107 static void |
104 process(struct kreq *req) | 108 process(struct kreq *req) |
105 { | 109 { |