diff options
author | Kim Alvefur <zash@zash.se> | 2019-01-18 02:03:40 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-01-18 02:03:40 +0100 |
commit | 4d5f1da475da390dab6e8835f8159d868fe8c5b3 (patch) | |
tree | ca5a098b75459e1d6e4ed6ed183b5f83d8b6c3fb /plugins/mod_http.lua | |
parent | 26542811eafd9c708a130272d7b7de77b92712de (diff) | |
download | prosody-4d5f1da475da390dab6e8835f8159d868fe8c5b3.tar.gz prosody-4d5f1da475da390dab6e8835f8159d868fe8c5b3.zip |
mod_http: Set up to handle OPTIONS
Lower priority to allow http modules to handle it themselves, should
they wish to
Diffstat (limited to 'plugins/mod_http.lua')
-rw-r--r-- | plugins/mod_http.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 07d1094b..01f20f76 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -119,9 +119,15 @@ function module.add_host(module) apply_cors_headers(response, opt_methods, opt_headers, opt_max_age, request.headers.origin); end + local function options_handler(event_data) + cors_handler(event_data); + return ""; + end + for key, handler in pairs(event.item.route or {}) do local event_name = get_http_event(host, app_path, key); if event_name then + local options_event_name = event_name:gsub("^%S+", "OPTIONS"); if type(handler) ~= "function" then local data = handler; handler = function () return data; end @@ -140,6 +146,7 @@ function module.add_host(module) app_handlers[event_name] = handler; module:hook_object_event(server, event_name, handler); module:hook_object_event(server, event_name, cors_handler, 1); + module:hook_object_event(server, options_event_name, options_handler, -1); else module:log("warn", "App %s added handler twice for '%s', ignoring", app_name, event_name); end |