From edb861da707faf8b3e87154d0a38168defcbc0f8 Mon Sep 17 00:00:00 2001 From: cpq Date: Mon, 5 Sep 2022 12:29:06 +0100 Subject: [PATCH] docs --- docs/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 990edf16..f1550101 100644 --- a/docs/README.md +++ b/docs/README.md @@ -376,11 +376,11 @@ This example is a simple HTTP server that serves both static and dynamic content 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/hello")) { - mg_http_reply(c, 200, "", "{%Q:%d}\n", "status", 1); // Dynamic JSON response - } else { - struct mg_http_serve_opts opts = {.root_dir = "."}; // Serve static content - mg_http_serve_dir(c, hm, &opts); // Web UI from root_dir + if (mg_http_match_uri(hm, "/api/hello")) { // On /api/hello requests, + mg_http_reply(c, 200, "", "{%Q:%d}\n", "status", 1); // Send dynamic JSON response + } else { // For all other URIs, + struct mg_http_serve_opts opts = {.root_dir = "."}; // Serve files + mg_http_serve_dir(c, hm, &opts); // From root_dir } } }