Mercurial > prosody-modules
comparison mod_candy/mod_candy.lua @ 933:5a975ba6a845
mod_candy: Example of how easy it is to serve files from a prosody module
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 24 Mar 2013 23:58:40 +0100 |
parents | |
children | 6b34cc81e15d |
comparison
equal
deleted
inserted
replaced
932:4e235e565693 | 933:5a975ba6a845 |
---|---|
1 -- mod_candy.lua | |
2 -- Copyright (C) 2013 Kim Alvefur | |
3 -- | |
4 -- Run this in www_files | |
5 -- curl -L http://github.com/candy-chat/candy/tarball/master | tar xzfv - --strip-components=1 | |
6 | |
7 local json_encode = require"util.json".encode; | |
8 | |
9 local serve = module:depends"http_files".serve; | |
10 | |
11 module:provides("http", { | |
12 route = { | |
13 ["GET /prosody.js"] = function(event) | |
14 event.response.headers.content_type = "text/javascript"; | |
15 return ("// Generated by Prosody\n" | |
16 .."var Prosody = %s;\n") | |
17 :format(json_encode({ | |
18 bosh_path = module:http_url("bosh","/http-bind"); | |
19 version = prosody.version; | |
20 host = module:get_host(); | |
21 anonymous = module:get_option_string("authentication") == "anonymous"; | |
22 })); | |
23 end; | |
24 ["GET /*"] = serve(module:get_directory().."/www_files"); | |
25 } | |
26 }); | |
27 |