mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-21 11:30:01 +00:00
Update to use MG_ESC()
This commit is contained in:
1 parent
f4cf40d38f
commit
1908d3200e
8 files changed
+46
-56
No files matched your search
@@ -52,14 +52,12 @@ void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
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",
|
||||
"{%m:%m,%m:%m}\n", mg_print_esc, 0, "text", mg_print_esc, 0,
|
||||
"Hello!", mg_print_esc, 0, "data", mg_print_esc, 0,
|
||||
"somedata");
|
||||
"{%m:%m,%m:%m}\n", MG_ESC("text"), MG_ESC("Hello!"),
|
||||
MG_ESC("data"), MG_ESC("somedata"));
|
||||
} else if (mg_http_match_uri(hm, "/api/login")) {
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n",
|
||||
"{%m:%m,%m:%m}\n", mg_print_esc, 0, "user", mg_print_esc, 0,
|
||||
u->name, mg_print_esc, 0, "token", mg_print_esc, 0,
|
||||
u->token);
|
||||
"{%m:%m,%m:%m}\n", MG_ESC("user"), MG_ESC(u->name),
|
||||
MG_ESC("token"), MG_ESC(u->token));
|
||||
} else {
|
||||
struct mg_http_serve_opts opts = {.root_dir = "web_root"};
|
||||
mg_http_serve_dir(c, ev_data, &opts);
|
||||
|
||||
Reference in new issue
Block a user