comparison plugins/mod_http_files.lua @ 12977:74b9e05af71e

plugins: Prefix module imports with prosody namespace
author Kim Alvefur <zash@zash.se>
date Fri, 24 Mar 2023 13:15:28 +0100
parents ba05f7e5f2a2
children 50324f66ca2a
comparison
equal deleted inserted replaced
12976:a187600ec7d6 12977:74b9e05af71e
7 -- 7 --
8 8
9 module:depends("http"); 9 module:depends("http");
10 10
11 local open = io.open; 11 local open = io.open;
12 local fileserver = require"net.http.files"; 12 local fileserver = require"prosody.net.http.files";
13 13
14 local base_path = module:get_option_path("http_files_dir", module:get_option_path("http_path")); 14 local base_path = module:get_option_path("http_files_dir", module:get_option_path("http_path"));
15 local cache_size = module:get_option_number("http_files_cache_size", 128); 15 local cache_size = module:get_option_number("http_files_cache_size", 128);
16 local cache_max_file_size = module:get_option_number("http_files_cache_max_file_size", 4096); 16 local cache_max_file_size = module:get_option_number("http_files_cache_max_file_size", 4096);
17 local dir_indices = module:get_option_array("http_index_files", { "index.html", "index.htm" }); 17 local dir_indices = module:get_option_array("http_index_files", { "index.html", "index.htm" });
72 opts.cache_max_file_size = cache_max_file_size; 72 opts.cache_max_file_size = cache_max_file_size;
73 end 73 end
74 if opts.index_files == nil then 74 if opts.index_files == nil then
75 opts.index_files = dir_indices; 75 opts.index_files = dir_indices;
76 end 76 end
77 module:log("warn", "%s should be updated to use 'net.http.files' instead of mod_http_files", get_calling_module()); 77 module:log("warn", "%s should be updated to use 'prosody.net.http.files' instead of mod_http_files", get_calling_module());
78 return fileserver.serve(opts); 78 return fileserver.serve(opts);
79 end 79 end
80 80
81 function wrap_route(routes) 81 function wrap_route(routes)
82 module:log("debug", "%s should be updated to use 'net.http.files' instead of mod_http_files", get_calling_module()); 82 module:log("debug", "%s should be updated to use 'prosody.net.http.files' instead of mod_http_files", get_calling_module());
83 for route,handler in pairs(routes) do 83 for route,handler in pairs(routes) do
84 if type(handler) ~= "function" then 84 if type(handler) ~= "function" then
85 routes[route] = fileserver.serve(handler); 85 routes[route] = fileserver.serve(handler);
86 end 86 end
87 end 87 end