MCPcopy Create free account
hub / github.com/cesanta/mongoose / cb

Function cb

tutorials/http/file-upload-multiple-posts/main.c:9–19  ·  view source on GitHub ↗

HTTP request handler function. It implements the following endpoints: /upload - Saves the next file chunk all other URI - serves web_root/ directory

Source from the content-addressed store, hash-verified

7// /upload - Saves the next file chunk
8// all other URI - serves web_root/ directory
9static 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
21int main(void) {
22 struct mg_mgr mgr;

Callers

nothing calls this directly

Calls 4

mg_matchFunction · 0.50
mg_strClass · 0.50
mg_http_uploadFunction · 0.50
mg_http_serve_dirFunction · 0.50

Tested by

no test coverage detected