HTTP request handler function. It implements the following endpoints: /upload - Saves the next file chunk all other URI - serves web_root/ directory
| 7 | // /upload - Saves the next file chunk |
| 8 | // all other URI - serves web_root/ directory |
| 9 | static void cb(struct mg_connection *c, int ev, void *ev_data) { |
| 10 | if (ev == MG_EV_HTTP_MSG) { |
| 11 | struct mg_http_message *hm = (struct mg_http_message *) ev_data; |
| 12 | if (mg_match(hm->uri, mg_str("/upload"), NULL)) { |
| 13 | mg_http_upload(c, hm, &mg_fs_posix, "/tmp", 99999); |
| 14 | } else { |
| 15 | struct mg_http_serve_opts opts = {.root_dir = "web_root"}; |
| 16 | mg_http_serve_dir(c, ev_data, &opts); |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | int main(void) { |
| 22 | struct mg_mgr mgr; |
nothing calls this directly
no test coverage detected