From 65ee63d43ef92553cd3650b3e276d71e2f7daec5 Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Sun, 29 Apr 2018 17:58:34 -0400 Subject: [PATCH] added HTML5 fallback option This is not part of the project requirements --- src/globals.h | 1 + src/main.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/globals.h b/src/globals.h index 2051ca5..5483702 100644 --- a/src/globals.h +++ b/src/globals.h @@ -6,3 +6,4 @@ extern char *server_root; extern bool silent_mode; extern int token_expiration_time; +extern bool html5_fallback; diff --git a/src/main.c b/src/main.c index 6873983..fe51d23 100644 --- a/src/main.c +++ b/src/main.c @@ -15,6 +15,12 @@ #include "bufio.h" #include "globals.h" +/* Implement HTML5 fallback. + * This means that if a non-API path refers to a file and that + * file is not found or is a directory, return /index.html + * instead. Otherwise, return the file. + */ +bool html5_fallback = false; bool silent_mode = false; int token_expiration_time = 24 * 60 * 60; // default token expiration time is 1 day @@ -56,8 +62,12 @@ main(int ac, char *av[]) { int opt; char *port_string = NULL; - while ((opt = getopt(ac, av, "hp:R:se:")) != -1) { + while ((opt = getopt(ac, av, "ahp:R:se:")) != -1) { switch (opt) { + case 'a': + html5_fallback = true; + break; + case 'p': port_string = optarg; break;