From 4c66b3e2842de2c196fd3e3722861ff515e91969 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 23 Dec 2012 11:17:44 +0100 Subject: mod_http_files: Allow passing a string to serve() --- plugins/mod_http_files.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3