comparison mod_rest/apidemo.lib.lua @ 4929:d5612dcf6733

mod_rest/apidemo: Don't show traceback to users on config/resource problem
author Kim Alvefur <zash@zash.se>
date Sun, 17 Apr 2022 12:52:13 +0200
parents 1c6d353550cc
children d03448560acf
comparison
equal deleted inserted replaced
4928:77b7e1322281 4929:d5612dcf6733
9 path = api_demo; 9 path = api_demo;
10 mime_map = mime_map; 10 mime_map = mime_map;
11 }); 11 });
12 12
13 local index do 13 local index do
14 local f = assert(io.open(api_demo.."/index.html"), "'rest_demo_resources' should point to the 'dist' directory"); 14 local f, err = io.open(api_demo.."/index.html");
15 if not f then
16 module:log("error", "Could not open resource: %s", err);
17 module:log("error", "'rest_demo_resources' should point to the 'dist' directory");
18 return _M
19 end
15 index = f:read("*a"); 20 index = f:read("*a");
16 f:close(); 21 f:close();
17 22
18 -- SUCH HACK, VERY GSUB, WOW! 23 -- SUCH HACK, VERY GSUB, WOW!
19 index = index:gsub("(%s?url%s*:%s*)%b\"\"", string.format("%%1%q", module:http_url().."/demo/openapi.yaml"), 1); 24 index = index:gsub("(%s?url%s*:%s*)%b\"\"", string.format("%%1%q", module:http_url().."/demo/openapi.yaml"), 1);