Mercurial > prosody-modules
comparison mod_http_hostaliases/mod_http_hostaliases.lua @ 2265:29e3a09275c5
mod_http_hostaliases: Give HTTP hosts additional aliases
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 09 Aug 2016 14:23:30 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2264:463e43dc0c4d | 2265:29e3a09275c5 |
---|---|
1 module:set_global(); | |
2 | |
3 local host_map = { }; | |
4 | |
5 module:wrap_object_event(require "net.http.server"._events, false, function (handlers, event_name, event_data) | |
6 local verb, host, path = event_name:match("^(%w+ )(.-)(/.*)"); | |
7 host = host_map[host]; | |
8 event_name = verb .. host .. path; | |
9 return handlers(event_name, event_data); | |
10 end); | |
11 | |
12 function module.add_host(module) | |
13 local http_host = module:get_option_string("http_host"); | |
14 for host in module:get_option_set("http_host_aliases", {}) do | |
15 host_map[host] = http_host; | |
16 end | |
17 end |