mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-08 08:54:54 +07:00
Add extra param to http_reply()
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// Event handler for an accepted connection
|
||||
static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
if (ev == MG_EV_HTTP_MSG) {
|
||||
mg_http_reply(c, 200, "Hello from ESP32!");
|
||||
mg_http_reply(c, 200, "", "Hello from ESP32!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (mg_http_match_uri(hm, "/api/f1")) {
|
||||
mg_http_reply(c, 200, "{\"result\": %d}\n", 123); // Serve REST response
|
||||
mg_http_reply(c, 200, "", "{\"result\": %d}\n", 123); // Serve REST
|
||||
} else if (mg_http_match_uri(hm, "/api/f2/*")) {
|
||||
mg_http_reply(c, 200, "{\"result\": \"%.*s\"}\n", (int) hm->uri.len,
|
||||
mg_http_reply(c, 200, "", "{\"result\": \"%.*s\"}\n", (int) hm->uri.len,
|
||||
hm->uri.ptr);
|
||||
} else {
|
||||
mg_http_serve_dir(c, ev_data, s_web_directory); // Serve static files
|
||||
|
||||
@@ -24,7 +24,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
mg_ws_upgrade(c, hm);
|
||||
} else if (mg_http_match_uri(hm, "/rest")) {
|
||||
// Serve REST response
|
||||
mg_http_reply(c, 200, "{\"result\": %d}\n", 123);
|
||||
mg_http_reply(c, 200, "", "{\"result\": %d}\n", 123);
|
||||
} else {
|
||||
// Serve static files
|
||||
mg_http_serve_dir(c, ev_data, s_web_directory);
|
||||
|
||||
Reference in New Issue
Block a user