# HG changeset patch # User Kim Alvefur # Date 1356257864 -3600 # Node ID 69964d1cbe6624b4f9225972f99c6d8dbad1158c # Parent a2080e5c4eda360976f94ce794f4af2442d6672c mod_http_files: Allow passing a string to serve() diff -r a2080e5c4eda -r 69964d1cbe66 plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Sat Dec 22 14:20:12 2012 +0100 +++ b/plugins/mod_http_files.lua Sun Dec 23 11:17:44 2012 +0100 @@ -51,6 +51,9 @@ 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 @@ 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