# HG changeset patch # User Matthew Wild # Date 1611255282 0 # Node ID 3d01bc4547b259cd82248fdefe9961abcae78190 # Parent dee6b509827809b5da322ac97de73e232748336d mod_http_admin_api: Add /server/info endpoint for site_name and version diff -r dee6b5098278 -r 3d01bc4547b2 mod_http_admin_api/mod_http_admin_api.lua --- a/mod_http_admin_api/mod_http_admin_api.lua Thu Jan 21 18:06:12 2021 +0000 +++ b/mod_http_admin_api/mod_http_admin_api.lua Thu Jan 21 18:54:42 2021 +0000 @@ -14,6 +14,8 @@ local group_memberships = module:open_store("groups", "map"); local push_errors = module:shared("cloud_notify/push_errors"); +local site_name = module:get_option_string("site_name", module.host); + local json_content_type = "application/json"; local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); @@ -501,6 +503,14 @@ return 200; end +local function get_server_info(event) + event.response.headers["Content-Type"] = json_content_type; + return json.encode({ + site_name = site_name; + version = prosody.version; + }); +end + module:provides("http", { route = check_auth { ["GET /invites"] = list_invites; @@ -517,5 +527,7 @@ ["POST /groups"] = create_group; ["PUT /groups/*"] = update_group; ["DELETE /groups/*"] = delete_group; + + ["GET /server/info"] = get_server_info; }; });