Mercurial > prosody-modules
comparison mod_http_libjs/mod_http_libjs.lua @ 4604:f0efbb0b0b5b
mod_http_libjs: Check that the path to serve exists
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Jun 2021 12:41:43 +0200 |
parents | de2390d6bbe4 |
children | 75b6e5df65f9 |
comparison
equal
deleted
inserted
replaced
4603:3a42789d7235 | 4604:f0efbb0b0b5b |
---|---|
11 serve = module:depends"http_files".serve; | 11 serve = module:depends"http_files".serve; |
12 end | 12 end |
13 | 13 |
14 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"); |
15 | 15 |
16 do -- sanity check | |
17 local lfs = require "lfs"; | |
18 | |
19 local exists, err = lfs.attributes(libjs_path, "mode"); | |
20 if exists ~= "directory" then | |
21 module:log("error", "Problem with 'libjs_path': %s", err or "not a directory"); | |
22 end | |
23 end | |
24 | |
16 module:provides("http", { | 25 module:provides("http", { |
17 default_path = "/share"; | 26 default_path = "/share"; |
18 route = { | 27 route = { |
19 ["GET /*"] = serve({ path = libjs_path, mime_map = mime_map }); | 28 ["GET /*"] = serve({ path = libjs_path, mime_map = mime_map }); |
20 } | 29 } |