Software /
code /
prosody
Diff
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 |
line wrap: on
line diff
--- a/plugins/mod_http.lua Fri Sep 21 15:34:45 2018 +0200 +++ b/plugins/mod_http.lua Fri Sep 21 21:19:41 2018 +0200 @@ -172,7 +172,13 @@ -- Not included in eg http-error events request.ip = get_ip_from_request(request); end - return handlers(event_name, event_data); + local ret = handlers(event_name, event_data); + if ret ~= nil then + return ret; + end + local host = (request.headers.host or ""):match("[^:]+"); + local host_event = request.method.." "..host..request.path:match("[^?]*"); + return handlers(host_event, event_data); end); module:provides("net", {