27 end |
27 end |
28 path = normalize_path(path); |
28 path = normalize_path(path); |
29 return method:upper().." "..host..app_path..path; |
29 return method:upper().." "..host..app_path..path; |
30 end |
30 end |
31 |
31 |
|
32 local function get_base_path(host_module, app_name, default_app_path) |
|
33 return host_module:get_option("http_paths", {})[app_name] -- Host |
|
34 or module:get_option("http_paths", {})[app_name] -- Global |
|
35 or default_app_path; -- Default |
|
36 end |
|
37 |
32 function module.add_host(module) |
38 function module.add_host(module) |
33 local host = module.host; |
39 local host = module.host; |
34 local apps = {}; |
40 local apps = {}; |
35 module.environment.apps = apps; |
41 module.environment.apps = apps; |
36 local function http_app_added(event) |
42 local function http_app_added(event) |
37 local app_name = event.item.name; |
43 local app_name = event.item.name; |
38 local default_app_path = event.item.default_path or "/"..app_name; |
44 local default_app_path = event.item.default_path or "/"..app_name; |
39 local app_path = normalize_path(module:get_option_string(app_name.."_http_path", default_app_path)); |
45 local app_path = normalize_path(get_base_path(module, app_name, default_app_path)); |
40 if not app_name then |
46 if not app_name then |
41 -- TODO: Link to docs |
47 -- TODO: Link to docs |
42 module:log("error", "HTTP app has no 'name', add one or use module:provides('http', app)"); |
48 module:log("error", "HTTP app has no 'name', add one or use module:provides('http', app)"); |
43 return; |
49 return; |
44 end |
50 end |