diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-05-20 19:25:16 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-05-20 19:27:21 +0200 |
commit | e68a315bcf2bd681466c27026fea73598071bda6 (patch) | |
tree | 57fb5e32babf8757b00524f9c522c59491501621 /src/afb-hsrv.c | |
parent | c044f0961a1c276a13791e7559027505c5292073 (diff) |
fix one-page-application redirect
Change-Id: I80c4dbda86cd1bc2847dea5b1dea304f41c551e6
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hsrv.c')
-rw-r--r-- | src/afb-hsrv.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index 46e61a01..886820d6 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -302,6 +302,19 @@ static struct hsrv_handler *new_handler( return head; } +static int handle_alias_relax(struct afb_hreq *hreq, void *data) +{ + struct hsrv_alias *da = data; + + if (hreq->method != afb_method_get) + return 0; + + if (!afb_hreq_valid_tail(hreq)) + return 0; + + return afb_hreq_reply_file_if_exist(hreq, da->dirfd, &hreq->tail[1]); +} + static int handle_alias(struct afb_hreq *hreq, void *data) { struct hsrv_alias *da = data; @@ -335,7 +348,7 @@ int afb_hsrv_add_handler( return 1; } -int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *alias, int priority) +int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *alias, int priority, int relax) { struct hsrv_alias *da; int dirfd; @@ -351,7 +364,7 @@ int afb_hsrv_add_alias(struct afb_hsrv *hsrv, const char *prefix, const char *al da->directory = alias; da->lendir = strlen(da->directory); da->dirfd = dirfd; - if (afb_hsrv_add_handler(hsrv, prefix, handle_alias, da, priority)) + if (afb_hsrv_add_handler(hsrv, prefix, relax ? handle_alias_relax : handle_alias, da, priority)) return 1; free(da); } |