From 9e0f04dc8b3a693b52258df951c07d2c8c1c6d67 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 20 Dec 2021 16:35:16 +0000 Subject: [PATCH] Add -S option --- examples/http-server/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/http-server/main.c b/examples/http-server/main.c index f775d5ee..b2be19c4 100644 --- a/examples/http-server/main.c +++ b/examples/http-server/main.c @@ -8,6 +8,7 @@ static const char *s_debug_level = "2"; static const char *s_root_dir = "."; // Attention: avoid double-dots, `..` ! static const char *s_listening_address = "http://localhost:8000"; static const char *s_enable_hexdump = "no"; +static const char *s_ssi_pattern = "#.html"; // Handle interrupts, like Ctrl-C static int s_signo; @@ -21,6 +22,7 @@ static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { if (ev == MG_EV_HTTP_MSG) { struct mg_http_serve_opts opts = {0}; opts.root_dir = s_root_dir; + opts.ssi_pattern = s_ssi_pattern; mg_http_serve_dir(c, ev_data, &opts); } (void) fn_data; @@ -31,11 +33,12 @@ static void usage(const char *prog) { "Mongoose v.%s\n" "Usage: %s OPTIONS\n" " -H yes|no - enable traffic hexdump, default: '%s'\n" + " -S PAT - SSI filename pattern, default: '%s'\n" " -d DIR - directory to serve, default: '%s'\n" " -l ADDR - listening address, default: '%s'\n" " -v LEVEL - debug level, from 0 to 4, default: '%s'\n", - MG_VERSION, prog, s_enable_hexdump, s_root_dir, s_listening_address, - s_debug_level); + MG_VERSION, prog, s_enable_hexdump, s_ssi_pattern, s_root_dir, + s_listening_address, s_debug_level); exit(EXIT_FAILURE); } @@ -50,6 +53,8 @@ int main(int argc, char *argv[]) { s_root_dir = argv[++i]; } else if (strcmp(argv[i], "-H") == 0) { s_enable_hexdump = argv[++i]; + } else if (strcmp(argv[i], "-S") == 0) { + s_ssi_pattern = argv[++i]; } else if (strcmp(argv[i], "-l") == 0) { s_listening_address = argv[++i]; } else if (strcmp(argv[i], "-v") == 0) {