mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Make mg_http_serve_file public
A way to serve a single, specific file as opposed to the hairy monster that is mg_serve_http. PUBLISHED_FROM=6ed1bc487b9d41d212a5907337182f23b040aecf
This commit is contained in:
1 parent
1070dd2d87
commit
5fa544fc78
4 files changed
+86
-23
No files matched your search
+23
@@ -2687,6 +2687,29 @@ struct mg_serve_http_opts {
|
||||
void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
|
||||
struct mg_serve_http_opts opts);
|
||||
|
||||
/*
|
||||
* Serves a specific file with a given MIME type and optional extra headers.
|
||||
*
|
||||
* Example code snippet:
|
||||
*
|
||||
* ```c
|
||||
* static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
* switch (ev) {
|
||||
* case MG_EV_HTTP_REQUEST: {
|
||||
* struct http_message *hm = (struct http_message *) ev_data;
|
||||
* mg_http_serve_file(nc, hm, "file.txt",
|
||||
* mg_mk_str("text/plain"), mg_mk_str(""));
|
||||
* break;
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
|
||||
const char *path, const struct mg_str mime_type,
|
||||
const struct mg_str extra_headers);
|
||||
|
||||
/*
|
||||
* Registers a callback for a specified http endpoint
|
||||
* Note: if callback is registered it is called instead of the
|
||||
|
||||
Reference in new issue
Block a user