Software /
code /
prosody-modules
Comparison
mod_rest/mod_rest.lua @ 4488:eea62d30ae08
mod_rest: Add option for serving interactive openapi documentation
Swagger not included.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 02 Mar 2021 18:38:13 +0100 |
parent | 4481:e453eaf1589e |
child | 4502:48afaec5d1de |
comparison
equal
deleted
inserted
replaced
4487:f877a4d3770b | 4488:eea62d30ae08 |
---|---|
307 module:send(payload, origin); | 307 module:send(payload, origin); |
308 return 202; | 308 return 202; |
309 end | 309 end |
310 end | 310 end |
311 | 311 |
312 local demo_handlers = {}; | |
313 if module:get_option_path("rest_demo_resources", nil) then | |
314 demo_handlers = module:require"apidemo"; | |
315 end | |
316 | |
312 -- Handle stanzas submitted via HTTP | 317 -- Handle stanzas submitted via HTTP |
313 module:depends("http"); | 318 module:depends("http"); |
314 module:provides("http", { | 319 module:provides("http", { |
315 route = { | 320 route = { |
316 POST = handle_request; | 321 POST = handle_request; |
317 ["POST /*"] = handle_request; | 322 ["POST /*"] = handle_request; |
318 ["GET /*"] = handle_request; | 323 ["GET /*"] = handle_request; |
324 | |
325 -- Only if api_demo_resources are set | |
326 ["GET /"] = demo_handlers.redirect; | |
327 ["GET /demo/"] = demo_handlers.main_page; | |
328 ["GET /demo/openapi.yaml"] = demo_handlers.schema; | |
329 ["GET /demo/*"] = demo_handlers.resources; | |
319 }; | 330 }; |
320 }); | 331 }); |
321 | 332 |
322 -- Forward stanzas from XMPP to HTTP and return any reply | 333 -- Forward stanzas from XMPP to HTTP and return any reply |
323 local rest_url = module:get_option_string("rest_callback_url", nil); | 334 local rest_url = module:get_option_string("rest_callback_url", nil); |