Mercurial > prosody-modules
diff mod_stanza_counter/mod_stanza_counter_http.lua @ 535:39c7115be370
mod_stanza_counter_http: replaced prosody.events.add_handler with module:hook.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Sun, 08 Jan 2012 03:52:38 +0000 |
parents | d4adda950546 |
children | b3f8435e661c |
line wrap: on
line diff
--- a/mod_stanza_counter/mod_stanza_counter_http.lua Sun Jan 08 03:52:06 2012 +0000 +++ b/mod_stanza_counter/mod_stanza_counter_http.lua Sun Jan 08 03:52:38 2012 +0000 @@ -15,11 +15,11 @@ local function res(code, r, h) local response = { - status = code; - body = r; - } + status = code, + body = r + } - if h then response.headers = h; end + if h then response.headers = h end return response end @@ -33,7 +33,7 @@ prosody.stanza_counter.message["incoming"], prosody.stanza_counter.message["outgoing"], prosody.stanza_counter.presence["incoming"], - prosody.stanza_counter.presence["outgoing"]); + prosody.stanza_counter.presence["outgoing"]) return res(200, forge_res) else local err405 = r_err:format("405", "Only GET is supported") @@ -47,5 +47,5 @@ httpserver.new_from_config(ports, req, { base = "stanza-counter" }) end --- hook server started -module:hook("server-started", setup) +-- set it +if prosody.start_time then setup() else module:hook("server-started", setup) end