equal
deleted
inserted
replaced
36 return nil; |
36 return nil; |
37 end |
37 end |
38 if app_path == "/" and path:sub(1,1) == "/" then |
38 if app_path == "/" and path:sub(1,1) == "/" then |
39 app_path = ""; |
39 app_path = ""; |
40 end |
40 end |
41 if host == "*" then |
41 return method:upper().." "..host..app_path..path; |
42 return method:upper().." "..app_path..path; |
|
43 else |
|
44 return method:upper().." "..host..app_path..path; |
|
45 end |
|
46 end |
42 end |
47 |
43 |
48 local function get_base_path(host_module, app_name, default_app_path) |
44 local function get_base_path(host_module, app_name, default_app_path) |
49 return (normalize_path(host_module:get_option("http_paths", {})[app_name] -- Host |
45 return (normalize_path(host_module:get_option("http_paths", {})[app_name] -- Host |
50 or module:get_option("http_paths", {})[app_name] -- Global |
46 or module:get_option("http_paths", {})[app_name] -- Global |
174 local request = event_data.request; |
170 local request = event_data.request; |
175 if request then |
171 if request then |
176 -- Not included in eg http-error events |
172 -- Not included in eg http-error events |
177 request.ip = get_ip_from_request(request); |
173 request.ip = get_ip_from_request(request); |
178 end |
174 end |
179 local ret = handlers(event_name, event_data); |
175 return handlers(event_name, event_data); |
180 if ret ~= nil then |
|
181 return ret; |
|
182 end |
|
183 local host = (request.headers.host or ""):match("[^:]+"); |
|
184 local host_event = request.method.." "..host..request.path:match("[^?]*"); |
|
185 return handlers(host_event, event_data); |
|
186 end); |
176 end); |
187 |
177 |
188 module:provides("net", { |
178 module:provides("net", { |
189 name = "http"; |
179 name = "http"; |
190 listener = server.listener; |
180 listener = server.listener; |