Update examples to use mg_http_reply

This commit is contained in:
cpq committed 2022-08-13 14:52:10 +01:00
1 parent 40ca26f23b
commit de10e340b6
5 files changed
+795 -797

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct user *u = getuser(hm);
if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
// All URIs starting with /api/ must be authenticated
mg_printf(c, "%s", "HTTP/1.1 403 Denied\r\nContent-Length: 0\r\n\r\n");
mg_http_reply(c, 403, "", "Denied\n");
} else if (mg_http_match_uri(hm, "/api/data")) {
mg_http_reply(c, 200, "Content-Type: application/json\r\n",
"{%Q:%Q,%Q:%Q}\n", "text", "Hello!", "data", "somedata");