Software / code / prosody-modules
Comparison
mod_http_libjs/mod_http_libjs.lua @ 6263:10a1016d1c3a
Merge update
| author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
|---|---|
| date | Sun, 01 Jun 2025 11:43:16 +0700 |
| parent | 6224:0bd1804baae7 |
comparison
equal
deleted
inserted
replaced
| 6262:a72388da5cd4 | 6263:10a1016d1c3a |
|---|---|
| 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 }); |