aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-12-23 11:17:44 +0100
committerKim Alvefur <zash@zash.se>2012-12-23 11:17:44 +0100
commit59db48f8cb71226bd12087c8a9148cf0a89c3f32 (patch)
treeec7174a7035716c903c153fd910b7166437eecca
parenta7f6283a2e582f5b6b0a920b6e0418ebb9c379d9 (diff)
downloadprosody-59db48f8cb71226bd12087c8a9148cf0a89c3f32.tar.gz
prosody-59db48f8cb71226bd12087c8a9148cf0a89c3f32.zip
mod_http_files: Allow passing a string to serve()
-rw-r--r--plugins/mod_http_files.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua
index a96db7b6..f1ae4918 100644
--- a/plugins/mod_http_files.lua
+++ b/plugins/mod_http_files.lua
@@ -51,6 +51,9 @@ end
local cache = setmetatable({}, { __mode = "kv" }); -- Let the garbage collector have it if it wants to.
function serve(opts)
+ if type(opts) ~= "table" then -- assume path string
+ opts = { path = opts };
+ end
local base_path = opts.path;
local dir_indices = opts.index_files or dir_indices;
local directory_index = opts.directory_index;
@@ -128,7 +131,7 @@ end
function wrap_route(routes)
for route,handler in pairs(routes) do
- if type(handler) == "table" and handler.path then
+ if type(handler) ~= "function" then
routes[route] = serve(handler);
end
end