Mercurial > sci
comparison scid/pageutil.c @ 50:b474f0985e39
scictl: add API key support
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 17 Aug 2022 09:11:58 +0200 |
parents | 16f1c72d1635 |
children | 71cd8447e3a4 |
comparison
equal
deleted
inserted
replaced
49:9d8df0c1db63 | 50:b474f0985e39 |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #include <assert.h> | 19 #include <assert.h> |
20 | 20 |
21 #include "pageutil.h" | 21 #include "pageutil.h" |
22 #include "scid.h" | |
22 #include "theme.h" | 23 #include "theme.h" |
23 #include "scid.h" | 24 #include "util.h" |
24 | 25 |
25 void | 26 void |
26 pageutil_render(struct kreq *req, | 27 pageutil_render(struct kreq *req, |
27 enum khttp status, | 28 enum khttp status, |
28 enum kmime mime, | 29 enum kmime mime, |
80 | 81 |
81 char *body; | 82 char *body; |
82 | 83 |
83 khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_APP_JSON]); | 84 khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_APP_JSON]); |
84 khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[status]); | 85 khttp_head(req, kresps[KRESP_STATUS], "%s", khttps[status]); |
86 khttp_body(req); | |
85 | 87 |
86 if (doc) { | 88 if (doc) { |
87 if ((body = json_dumps(doc, JSON_COMPACT))) { | 89 body = util_json_dump(doc); |
88 khttp_body(req); | 90 khttp_printf(req, "%s", body); |
89 khttp_printf(req, "%s", body); | |
90 } | |
91 | |
92 json_decref(doc); | 91 json_decref(doc); |
93 } | 92 } |
94 | 93 |
95 khttp_free(req); | 94 khttp_free(req); |
96 } | 95 } |