aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-21 06:13:19 +0100
committerKim Alvefur <zash@zash.se>2021-02-21 06:13:19 +0100
commit6d29fa653cb50f7e9624c704a1f2b3154dff6c04 (patch)
treeeb7bcac5034a66cfdc7945bbc73dcaced895087b /plugins
parent699e27da56f9b2774d7019470e3fce3c91a02726 (diff)
downloadprosody-6d29fa653cb50f7e9624c704a1f2b3154dff6c04.tar.gz
prosody-6d29fa653cb50f7e9624c704a1f2b3154dff6c04.zip
mod_http_errors: Add way to reuse the error page template
module:fire_event("http-message", {title = "hello"; message = "world"}) Goal is to enable consistent messages from Prosody. Not necessarily error messages, but warnings or just notices. This does cause some drift in the purpose of mod_http_errors, but that's okay.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http_errors.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/mod_http_errors.lua b/plugins/mod_http_errors.lua
index 2915a3e3..19433aee 100644
--- a/plugins/mod_http_errors.lua
+++ b/plugins/mod_http_errors.lua
@@ -64,6 +64,13 @@ module:hook_object_event(server, "http-error", function (event)
return get_page(event.code, (show_private and event.private_message) or event.message or (event.error and event.error.text));
end);
+module:hook("http-message", function (event)
+ if event.response then
+ event.response.headers.content_type = "text/html; charset=utf-8";
+ end
+ return render(html, event);
+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