Mercurial > prosody-modules
comparison mod_http_libjs/mod_http_libjs.lua @ 6192:0bd1804baae7
mod_http_libjs: Remove compatibility with 0.11
| author | Link Mauve <linkmauve@linkmauve.fr> |
|---|---|
| date | Wed, 09 Apr 2025 19:04:49 +0200 |
| parents | 75b6e5df65f9 |
| children |
comparison
equal
deleted
inserted
replaced
| 6191:767b8594fb9d | 6192:0bd1804baae7 |
|---|---|
| 1 local http_files = require "net.http.files"; | |
| 2 | |
| 1 local mime_map = module:shared("/*/http_files/mime").types or { | 3 local mime_map = module:shared("/*/http_files/mime").types or { |
| 2 css = "text/css", | 4 css = "text/css", |
| 3 js = "application/javascript", | 5 js = "application/javascript", |
| 4 }; | 6 }; |
| 5 | |
| 6 local serve; | |
| 7 if prosody.process_type == "prosody" then | |
| 8 local http_files = require "net.http.files"; | |
| 9 serve = http_files.serve; | |
| 10 else | |
| 11 serve = module:depends"http_files".serve; | |
| 12 end | |
| 13 | 7 |
| 14 local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript"); | 8 local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript"); |
| 15 | 9 |
| 16 do -- sanity check | 10 do -- sanity check |
| 17 local lfs = require "lfs"; | 11 local lfs = require "lfs"; |
| 23 end | 17 end |
| 24 | 18 |
| 25 module:provides("http", { | 19 module:provides("http", { |
| 26 default_path = "/share"; | 20 default_path = "/share"; |
| 27 route = { | 21 route = { |
| 28 ["GET /*"] = serve({ path = libjs_path, mime_map = mime_map }); | 22 ["GET /*"] = http_files.serve({ path = libjs_path, mime_map = mime_map }); |
| 29 } | 23 } |
| 30 }); | 24 }); |
