Mercurial > prosody-modules
comparison mod_http_libjs/mod_http_libjs.lua @ 4095:de2390d6bbe4
mod_http_libjs: Add compatibility with Prosody 0.11.x
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 11 Sep 2020 13:53:00 +0100 |
| parents | 88a469b285f5 |
| children | f0efbb0b0b5b |
comparison
equal
deleted
inserted
replaced
| 4094:dd00a2b9927c | 4095:de2390d6bbe4 |
|---|---|
| 1 local mime_map = module:shared("/*/http_files/mime").types or { | 1 local mime_map = module:shared("/*/http_files/mime").types or { |
| 2 css = "text/css", | 2 css = "text/css", |
| 3 js = "application/javascript", | 3 js = "application/javascript", |
| 4 }; | 4 }; |
| 5 | |
| 6 local serve; | |
| 7 if not pcall(function () | |
| 8 local http_files = require "net.http.files"; | |
| 9 serve = http_files.serve; | |
| 10 end) then | |
| 11 serve = module:depends"http_files".serve; | |
| 12 end | |
| 5 | 13 |
| 6 local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript"); | 14 local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript"); |
| 7 | 15 |
| 8 module:provides("http", { | 16 module:provides("http", { |
| 9 default_path = "/share"; | 17 default_path = "/share"; |
| 10 route = { | 18 route = { |
| 11 ["GET /*"] = require "net.http.files".serve({ path = libjs_path, mime_map = mime_map }); | 19 ["GET /*"] = serve({ path = libjs_path, mime_map = mime_map }); |
| 12 } | 20 } |
| 13 }); | 21 }); |
