--- a/mod_candy/mod_candy.lua Thu Jan 19 19:55:39 2017 +0100
+++ b/mod_candy/mod_candy.lua Fri Jan 20 01:09:36 2017 +0100
@@ -6,24 +6,25 @@
local serve = module:depends"http_files".serve;
+local function get_connect_path()
+ if is_module_loaded(module.host, "websocket") then
+ return module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws");
+ end
+ if not is_module_loaded(module.host, "bosh") then
+ module:depends("bosh");
+ end
+ return module:http_url("bosh", "/http-bind");
+end
+
module:provides("http", {
route = {
["GET /prosody.js"] = function(event)
event.response.headers.content_type = "text/javascript";
- local connect_path;
- if is_module_loaded(module.host, "websocket") then
- connect_path = module:http_url("websocket", "xmpp-websocket"):gsub("^http", "ws");
- else
- if not is_module_loaded(module.host, "bosh") then
- module:depends("bosh");
- end
- connect_path = module:http_url("bosh", "/http-bind");
- end
return ("// Generated by Prosody\n"
.."var Prosody = %s;\n")
:format(json_encode({
- connect_path = connect_path;
+ connect_path = get_connect_path();
version = prosody.version;
host = module:get_host();
anonymous = module:get_option_string("authentication") == "anonymous";