summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_route.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-09-19 02:47:09 +0300
committerValentin Bartenev <vbart@nginx.com>2019-09-19 02:47:09 +0300
commit08a8d1510d5f73d91112ead9e6ac075fb7d2bac0 (patch)
treef4dceb5af955f40820b0edbde4bdae41084c80ce /src/nxt_http_route.c
parentc554941b4f826d83d92d5ca8d7713bea4167896e (diff)
downloadunit-08a8d1510d5f73d91112ead9e6ac075fb7d2bac0.tar.gz
unit-08a8d1510d5f73d91112ead9e6ac075fb7d2bac0.tar.bz2
Basic support for serving static files.
Diffstat (limited to 'src/nxt_http_route.c')
-rw-r--r--src/nxt_http_route.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c
index 0b665573..c3c11faa 100644
--- a/src/nxt_http_route.c
+++ b/src/nxt_http_route.c
@@ -376,15 +376,9 @@ nxt_http_route_match_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_http_route_match_conf_t mtcf;
static nxt_str_t pass_path = nxt_string("/action/pass");
+ static nxt_str_t share_path = nxt_string("/action/share");
static nxt_str_t match_path = nxt_string("/match");
- pass_conf = nxt_conf_get_path(cv, &pass_path);
- if (nxt_slow_path(pass_conf == NULL)) {
- return NULL;
- }
-
- nxt_conf_get_string(pass_conf, &pass);
-
match_conf = nxt_conf_get_path(cv, &match_path);
n = (match_conf != NULL) ? nxt_conf_object_members_count(match_conf) : 0;
@@ -401,6 +395,19 @@ nxt_http_route_match_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
match->pass.handler = NULL;
match->items = n;
+ pass_conf = nxt_conf_get_path(cv, &pass_path);
+
+ if (pass_conf == NULL) {
+ pass_conf = nxt_conf_get_path(cv, &share_path);
+ if (nxt_slow_path(pass_conf == NULL)) {
+ return NULL;
+ }
+
+ match->pass.handler = nxt_http_static_handler;
+ }
+
+ nxt_conf_get_string(pass_conf, &pass);
+
string = nxt_str_dup(mp, &match->pass.name, &pass);
if (nxt_slow_path(string == NULL)) {
return NULL;
@@ -870,13 +877,18 @@ static void
nxt_http_route_resolve(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_http_route_t *route)
{
+ nxt_http_pass_t *pass;
nxt_http_route_match_t **match, **end;
match = &route->match[0];
end = match + route->items;
while (match < end) {
- nxt_http_pass_resolve(task, tmcf, &(*match)->pass);
+ pass = &(*match)->pass;
+
+ if (pass->handler == NULL) {
+ nxt_http_pass_resolve(task, tmcf, &(*match)->pass);
+ }
match++;
}