Mercurial > prosody-modules
comparison mod_rest/apidemo.lib.lua @ 4938:bc8832c6696b
upstream merge
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 11 May 2022 12:44:32 +0200 |
parents | d5612dcf6733 |
children | d03448560acf |
comparison
equal
deleted
inserted
replaced
4913:3ddab718f717 | 4938:bc8832c6696b |
---|---|
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); |