mod_bosh, mod_websocket: Add config options to override GET responses
authorMatthew Wild <mwild1@gmail.com>
Mon, 20 Apr 2020 11:30:59 +0100
changeset 10732 2764beb552cd
parent 10731 fa2a89132dfb
child 10733 dbce2b94a7eb
child 10761 9dec7cddb40b
mod_bosh, mod_websocket: Add config options to override GET responses
plugins/mod_bosh.lua
plugins/mod_websocket.lua
--- a/plugins/mod_bosh.lua	Sun Apr 19 13:04:12 2020 +0200
+++ b/plugins/mod_bosh.lua	Mon Apr 20 11:30:59 2020 +0100
@@ -511,14 +511,16 @@
 	end
 end
 
+local GET_response_body = [[<html><body>
+	<p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
+	<p>For more information see <a href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
+	</body></html>]];
+
 local GET_response = {
 	headers = {
 		content_type = "text/html";
 	};
-	body = [[<html><body>
-	<p>It works! Now point your BOSH client to this URL to connect to Prosody.</p>
-	<p>For more information see <a href="https://prosody.im/doc/setting_up_bosh">Prosody: Setting up BOSH</a>.</p>
-	</body></html>]];
+	body = module:get_option_string("bosh_get_response_body", GET_response_body);
 };
 
 module:depends("http");
--- a/plugins/mod_websocket.lua	Sun Apr 19 13:04:12 2020 +0200
+++ b/plugins/mod_websocket.lua	Mon Apr 20 11:30:59 2020 +0100
@@ -130,6 +130,12 @@
 
 	return data;
 end
+
+local default_get_response_body = [[<!DOCTYPE html><html><head><title>Websocket</title></head><body>
+<p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p>
+</body></html>]]
+local websocket_get_response_body = module:get_option_string("websocket_get_response_body", default_get_response_body)
+
 function handle_request(event)
 	local request, response = event.request, event.response;
 	local conn = response.conn;
@@ -138,9 +144,7 @@
 
 	if not request.headers.sec_websocket_key or request.method ~= "GET" then
 		response.headers.content_type = "text/html";
-		return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body>
-			<p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p>
-			</body></html>]];
+		return websocket_get_response_body;
 	end
 
 	local wants_xmpp = contains_token(request.headers.sec_websocket_protocol or "", "xmpp");