Mercurial > prosody-modules
comparison mod_http_admin_api/mod_http_admin_api.lua @ 4371:3d01bc4547b2
mod_http_admin_api: Add /server/info endpoint for site_name and version
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 21 Jan 2021 18:54:42 +0000 |
parents | 29b7f445aec5 |
children | e707810a943e |
comparison
equal
deleted
inserted
replaced
4370:dee6b5098278 | 4371:3d01bc4547b2 |
---|---|
11 | 11 |
12 local group_info_store = module:open_store("group_info"); | 12 local group_info_store = module:open_store("group_info"); |
13 local group_members_store = module:open_store("groups"); | 13 local group_members_store = module:open_store("groups"); |
14 local group_memberships = module:open_store("groups", "map"); | 14 local group_memberships = module:open_store("groups", "map"); |
15 local push_errors = module:shared("cloud_notify/push_errors"); | 15 local push_errors = module:shared("cloud_notify/push_errors"); |
16 | |
17 local site_name = module:get_option_string("site_name", module.host); | |
16 | 18 |
17 local json_content_type = "application/json"; | 19 local json_content_type = "application/json"; |
18 | 20 |
19 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); | 21 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); |
20 | 22 |
499 end | 501 end |
500 end | 502 end |
501 return 200; | 503 return 200; |
502 end | 504 end |
503 | 505 |
506 local function get_server_info(event) | |
507 event.response.headers["Content-Type"] = json_content_type; | |
508 return json.encode({ | |
509 site_name = site_name; | |
510 version = prosody.version; | |
511 }); | |
512 end | |
513 | |
504 module:provides("http", { | 514 module:provides("http", { |
505 route = check_auth { | 515 route = check_auth { |
506 ["GET /invites"] = list_invites; | 516 ["GET /invites"] = list_invites; |
507 ["GET /invites/*"] = get_invite_by_id; | 517 ["GET /invites/*"] = get_invite_by_id; |
508 ["POST /invites"] = create_invite; | 518 ["POST /invites"] = create_invite; |
515 ["GET /groups"] = list_groups; | 525 ["GET /groups"] = list_groups; |
516 ["GET /groups/*"] = get_group_by_id; | 526 ["GET /groups/*"] = get_group_by_id; |
517 ["POST /groups"] = create_group; | 527 ["POST /groups"] = create_group; |
518 ["PUT /groups/*"] = update_group; | 528 ["PUT /groups/*"] = update_group; |
519 ["DELETE /groups/*"] = delete_group; | 529 ["DELETE /groups/*"] = delete_group; |
530 | |
531 ["GET /server/info"] = get_server_info; | |
520 }; | 532 }; |
521 }); | 533 }); |