Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 9335:2dc7490899ae
net.http.server: Move handling of hosts to mod_http
Now an event like `GET /path` is fired at first, and mod\_http
dispatches the old `GET host/path` events.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 21 Sep 2018 21:19:41 +0200 |
parent | 8972:0b254439d451 |
child | 9336:9e8d7d461c7d |
comparison
equal
deleted
inserted
replaced
9334:a86736e0163c | 9335:2dc7490899ae |
---|---|
170 local request = event_data.request; | 170 local request = event_data.request; |
171 if request then | 171 if request then |
172 -- Not included in eg http-error events | 172 -- Not included in eg http-error events |
173 request.ip = get_ip_from_request(request); | 173 request.ip = get_ip_from_request(request); |
174 end | 174 end |
175 return handlers(event_name, event_data); | 175 local ret = handlers(event_name, event_data); |
176 if ret ~= nil then | |
177 return ret; | |
178 end | |
179 local host = (request.headers.host or ""):match("[^:]+"); | |
180 local host_event = request.method.." "..host..request.path:match("[^?]*"); | |
181 return handlers(host_event, event_data); | |
176 end); | 182 end); |
177 | 183 |
178 module:provides("net", { | 184 module:provides("net", { |
179 name = "http"; | 185 name = "http"; |
180 listener = server.listener; | 186 listener = server.listener; |