Comparison

mod_conversejs/mod_conversejs.lua @ 4976:75b6e5df65f9

various: Improve error reporting if missing file server module on 0.12 If there is some error loading net.http.files then it would be swallowed by the pcall and then it would proceed to trying mod_http_files, which might cause unexpected behavior on 0.12 Ref #1765
author Kim Alvefur <zash@zash.se>
date Mon, 18 Jul 2022 22:47:54 +0200
parent 4914:f2c918fe8cf0
child 5211:079ca766193b
comparison
equal deleted inserted replaced
4975:733e5513f691 4976:75b6e5df65f9
27 27
28 local serve_dist = nil; 28 local serve_dist = nil;
29 local resources = module:get_option_path("conversejs_resources"); 29 local resources = module:get_option_path("conversejs_resources");
30 if resources then 30 if resources then
31 local serve; 31 local serve;
32 if not pcall(function() 32 if prosody.process_type == "prosody" then
33 -- Prosody >= trunk / 0.12 33 -- Prosody >= trunk / 0.12
34 local http_files = require "net.http.files"; 34 local http_files = require "net.http.files";
35 serve = http_files.serve; 35 serve = http_files.serve;
36 end) then 36 else
37 -- Prosody <= 0.11 37 -- Prosody <= 0.11
38 serve = module:depends "http_files".serve; 38 serve = module:depends "http_files".serve;
39 end 39 end
40 local mime_map = module:shared("/*/http_files/mime").types or {css = "text/css"; js = "application/javascript"}; 40 local mime_map = module:shared("/*/http_files/mime").types or {css = "text/css"; js = "application/javascript"};
41 serve_dist = serve({path = resources; mime_map = mime_map}); 41 serve_dist = serve({path = resources; mime_map = mime_map});