Changeset

10430:46dd9df2db0c

mod_http_errors: Show a friendly page instead of 404 on top level
author Kim Alvefur <zash@zash.se>
date Sun, 17 Nov 2019 16:16:53 +0100
parents 10429:0b04d25c4ffb
children 10434:8f709577fe8e
files plugins/mod_http_errors.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_errors.lua	Sat Nov 23 17:15:34 2019 +0100
+++ b/plugins/mod_http_errors.lua	Sun Nov 17 16:16:53 2019 +0100
@@ -75,3 +75,15 @@
 	end
 	return get_page(event.code, (show_private and event.private_message) or event.message);
 end);
+
+module:hook_object_event(server, "http-error", function (event)
+	local request, response = event.request, event.response;
+	if request and response and request.path == "/" and response.status_code == 404 then
+		response.headers.content_type = "text/html; charset=utf-8";
+		return render(html, {
+				title = "Prosody is running!";
+				message = "Welcome to the XMPP world!";
+			});
+	end
+end, 1);
+