diff mod_conversejs/mod_conversejs.lua @ 3314:ab67f222d88b

mod_conversejs: Add an endpoint returning only initialization snippet
author Kim Alvefur <zash@zash.se>
date Mon, 10 Sep 2018 15:08:09 +0200
parents d6b922191aeb
children 2cf82cad1910
line wrap: on
line diff
--- a/mod_conversejs/mod_conversejs.lua	Mon Sep 10 15:07:07 2018 +0200
+++ b/mod_conversejs/mod_conversejs.lua	Mon Sep 10 15:08:09 2018 +0200
@@ -76,6 +76,13 @@
 			event.response.headers.content_type = "text/html";
 			return html_template:format(js_template:format(json_encode(converse_options)));
 		end;
+
+		["GET /prosody-converse.js"] = function (event)
+			local converse_options = get_converse_options();
+
+			event.response.headers.content_type = "application/javascript";
+			return js_template:format(json_encode(converse_options));
+		end;
 	}
 });