# HG changeset patch # User Kim Alvefur # Date 1554481103 -7200 # Node ID f1594893998f46be2817957c165a64e642831bbb # Parent afc48785f738af7d1a19ff1f3c241d2890f4f447 mod_http_files: Try to determine which module using serve() needs updating diff -r afc48785f738 -r f1594893998f plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Fri Apr 05 17:12:19 2019 +0200 +++ b/plugins/mod_http_files.lua Fri Apr 05 18:18:23 2019 +0200 @@ -46,6 +46,12 @@ end end +local function get_calling_module() + local info = debug.getinfo(3, "S"); + if not info then return "An unknown module"; end + return info.source:match"mod_[^/\\.]+" or info.short_src; +end + -- COMPAT -- TODO deprecate function serve(opts) if type(opts) ~= "table" then -- assume path string @@ -67,12 +73,12 @@ opts.index_files = dir_indices; end -- TODO Crank up to warning - module:log("debug", "Use of mod_http_files.serve() should be updated to use net.http.files"); + module:log("debug", "%s should be updated to use 'net.http.files' insead of mod_http_files", get_calling_module()); return fileserver.serve(opts); end function wrap_route(routes) - module:log("debug", "Use of mod_http_files.wrap_route() should be updated to use net.http.files"); + module:log("debug", "%s should be updated to use 'net.http.files' insead of mod_http_files", get_calling_module()); for route,handler in pairs(routes) do if type(handler) ~= "function" then routes[route] = fileserver.serve(handler);