fix spacing

This commit is contained in:
2026-04-11 15:08:22 -05:00
parent 599ea0fbb6
commit 3dc05cccb0

View File

@@ -1,23 +1,23 @@
#include "include/mongoose.h" #include "include/mongoose.h"
static void ev_handler(struct mg_connection *c, int ev, void *ev_data) { static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_HTTP_MSG) { if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data; struct mg_http_message *hm = (struct mg_http_message *)ev_data;
printf("URL: %.*s\n", (int) hm->uri.len, hm->uri.buf); printf("URL: %.*s\n", (int)hm->uri.len, hm->uri.buf);
if (mg_match(hm->uri, mg_str("/api/test"), NULL)) { if (mg_match(hm->uri, mg_str("/api/test"), NULL)) {
mg_http_reply(c, 200, "", "%s", "test"); mg_http_reply(c, 200, "", "%s", "test");
return; return;
}
mg_http_reply(c, 200, "", "%s", "<html>Hello world</html>");
} }
mg_http_reply(c, 200, "", "%s", "<html>Hello world</html>");
}
} }
int main() { int main() {
struct mg_mgr mgr; struct mg_mgr mgr;
mg_mgr_init(&mgr); mg_mgr_init(&mgr);
mg_http_listen(&mgr, "http://0.0.0.0:8000", ev_handler, NULL); mg_http_listen(&mgr, "http://0.0.0.0:8000", ev_handler, NULL);
for (;;) { for (;;) {
mg_mgr_poll(&mgr, 100); mg_mgr_poll(&mgr, 100);
} }
return 0; return 0;
} }