view mod_http_libjs/mod_http_libjs.lua @ 4452:6086fcf20da8

mod_muc_http_defaults: Minor schema tweak I think this makes more sense, after reading more about JSON Schema. Single field can't more than one of these two anyways.
author Kim Alvefur <zash@zash.se>
date Sat, 20 Feb 2021 20:16:24 +0100
parents de2390d6bbe4
children f0efbb0b0b5b
line wrap: on
line source

local mime_map = module:shared("/*/http_files/mime").types or {
	css = "text/css",
	js = "application/javascript",
};

local serve;
if not pcall(function ()
	local http_files = require "net.http.files";
	serve = http_files.serve;
end) then
	serve = module:depends"http_files".serve;
end

local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript");

module:provides("http", {
		default_path = "/share";
		route = {
			["GET /*"] = serve({ path = libjs_path, mime_map = mime_map });
		}
	});