Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 13209:c8d949cf6b09
plugins: Switch to :get_option_period() for time range options
Improves readability ("1 day" vs 86400) and centralizes validation.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 16 Jul 2023 20:49:33 +0200 |
parent | 13165:9c13c11b199d |
child | 13213:50324f66ca2a |
comparison
equal
deleted
inserted
replaced
13208:a7c6ea1c5308 | 13209:c8d949cf6b09 |
---|---|
36 local cors_overrides = module:get_option("http_cors_override", {}); | 36 local cors_overrides = module:get_option("http_cors_override", {}); |
37 local opt_methods = module:get_option_set("access_control_allow_methods", { "GET", "OPTIONS" }); | 37 local opt_methods = module:get_option_set("access_control_allow_methods", { "GET", "OPTIONS" }); |
38 local opt_headers = module:get_option_set("access_control_allow_headers", { "Content-Type" }); | 38 local opt_headers = module:get_option_set("access_control_allow_headers", { "Content-Type" }); |
39 local opt_origins = module:get_option_set("access_control_allow_origins"); | 39 local opt_origins = module:get_option_set("access_control_allow_origins"); |
40 local opt_credentials = module:get_option_boolean("access_control_allow_credentials", false); | 40 local opt_credentials = module:get_option_boolean("access_control_allow_credentials", false); |
41 local opt_max_age = module:get_option_number("access_control_max_age", 2 * 60 * 60); | 41 local opt_max_age = module:get_option_period("access_control_max_age", "2 hours"); |
42 local opt_default_cors = module:get_option_boolean("http_default_cors_enabled", true); | 42 local opt_default_cors = module:get_option_boolean("http_default_cors_enabled", true); |
43 | 43 |
44 local function get_http_event(host, app_path, key) | 44 local function get_http_event(host, app_path, key) |
45 local method, path = key:match("^(%S+)%s+(.+)$"); | 45 local method, path = key:match("^(%S+)%s+(.+)$"); |
46 if not method then -- No path specified, default to "" (base path) | 46 if not method then -- No path specified, default to "" (base path) |