From 95e22e8d4f10a9dabe9d61f835ae1111f098e042 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sun, 15 May 2022 14:40:58 +0100 Subject: [PATCH] Exporting only dashboard func --- examples/device-dashboard/main.c | 6 ++++-- examples/device-dashboard/web.c | 10 ++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/device-dashboard/main.c b/examples/device-dashboard/main.c index 40f5e92d..62736df0 100644 --- a/examples/device-dashboard/main.c +++ b/examples/device-dashboard/main.c @@ -3,11 +3,13 @@ #include "mongoose.h" -extern void run_web_server(struct mg_mgr *); +void device_dashboard_fn(struct mg_connection *, int, void *, void *); int main(void) { struct mg_mgr mgr; mg_mgr_init(&mgr); - run_web_server(&mgr); + mg_http_listen(&mgr, "http://0.0.0.0:8000", device_dashboard_fn, &mgr); + for (;;) mg_mgr_poll(&mgr, 1000); + mg_mgr_free(&mgr); return 0; } diff --git a/examples/device-dashboard/web.c b/examples/device-dashboard/web.c index 573e9b31..613ea15f 100644 --- a/examples/device-dashboard/web.c +++ b/examples/device-dashboard/web.c @@ -75,7 +75,8 @@ static void send_notification(struct mg_mgr *mgr, const char *name, } // HTTP request handler function -static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { +void device_dashboard_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; struct user *u = getuser(hm); @@ -124,10 +125,3 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { } } } - -void run_web_server(struct mg_mgr *mgr) { - s_config.value2 = strdup("hello"); - mg_http_listen(mgr, "http://0.0.0.0:8000", fn, mgr); - for (;;) mg_mgr_poll(mgr, 1000); - mg_mgr_free(mgr); -}