Changeset

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 4370:dee6b5098278
children 4372:78de3c7acf58
files mod_http_admin_api/mod_http_admin_api.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
 	};
 });