Comparison

plugins/mod_http.lua @ 4721:1c6c4c53f08a

mod_http: Routes now require a method to be specified, but the path has become optional (defaults to the base path with no trailing '/'
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Apr 2012 18:37:40 +0100
parent 4720:fddc2797a96a
child 4724:a8c234332258
comparison
equal deleted inserted replaced
4720:fddc2797a96a 4721:1c6c4c53f08a
16 return path; 16 return path;
17 end 17 end
18 18
19 local function get_http_event(host, app_path, key) 19 local function get_http_event(host, app_path, key)
20 local method, path = key:match("^(%S+)%s+(.+)$"); 20 local method, path = key:match("^(%S+)%s+(.+)$");
21 if not method then 21 if not method then -- No path specified, default to "" (base path)
22 if key:sub(1,1) ~= "/" then 22 method, path = key, "";
23 return nil;
24 end
25 method, path = "GET", key;
26 end 23 end
27 path = normalize_path(path); 24 if method:sub(1,1) == "/" then
25 return nil;
26 end
28 return method:upper().." "..host..app_path..path; 27 return method:upper().." "..host..app_path..path;
29 end 28 end
30 29
31 local function get_base_path(host_module, app_name, default_app_path) 30 local function get_base_path(host_module, app_name, default_app_path)
32 return host_module:get_option("http_paths", {})[app_name] -- Host 31 return host_module:get_option("http_paths", {})[app_name] -- Host