mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-19 11:09:42 +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
@@ -18,7 +18,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (mg_http_match_uri(hm, "/api/f1")) {
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "{%m:%d}\n",
|
||||
mg_print_esc, 0, "result", 123);
|
||||
MG_ESC("result"), 123);
|
||||
} else if (mg_http_match_uri(hm, "/api/sum")) {
|
||||
// Attempt to fetch a JSON array from the body, hm->body
|
||||
struct mg_str json = hm->body;
|
||||
@@ -27,7 +27,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
mg_json_get_num(json, "$[1]", &num2)) {
|
||||
// Success! create a JSON response
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "{%m:%g}\n",
|
||||
mg_print_esc, 0, "result", num1 + num2);
|
||||
MG_ESC("result"), num1 + num2);
|
||||
}
|
||||
} else {
|
||||
struct mg_http_serve_opts opts = {.root_dir = s_root_dir};
|
||||
|
||||
Reference in new issue
Block a user