# HG changeset patch # User Kim Alvefur # Date 1658145507 -7200 # Node ID 733e5513f69184c51bcb2ac8f017be48afa28400 # Parent 807007913f67c05d0a2af37501fa36c393849a77 various: Use 0.12+ API for serving files from the file system over HTTP Using mod_http_files this way is deprecated. Having the base behavior in a separate module makes it easier to have a specialized module with coherent behavior that does not do things when not explicitly enabled. diff -r 807007913f67 -r 733e5513f691 mod_invites_page/mod_invites_page.lua --- a/mod_invites_page/mod_invites_page.lua Mon Jul 11 20:08:41 2022 +0200 +++ b/mod_invites_page/mod_invites_page.lua Mon Jul 18 13:58:27 2022 +0200 @@ -33,7 +33,11 @@ -- Load HTTP-serving dependencies if prosody.shutdown then -- not if running under prosodyctl module:depends("http"); - http_files = module:depends("http_files"); + if not pcall(function () + http_files = require "net.http.files"; + end) then + http_files = module:depends"http_files"; + end end -- Calculate automatic base_url default base_url = module.http_url and module:http_url(); diff -r 807007913f67 -r 733e5513f691 mod_register_apps/mod_register_apps.lua --- a/mod_register_apps/mod_register_apps.lua Mon Jul 11 20:08:41 2022 +0200 +++ b/mod_register_apps/mod_register_apps.lua Mon Jul 18 13:58:27 2022 +0200 @@ -1,6 +1,13 @@ -- luacheck: ignore 631 module:depends("http"); -local http_files = module:depends("http_files"); +local http_files +if not pcall(function() + -- Prosody >= 0.12 + http_files = require "net.http.files"; +end) then + -- Prosody <= 0.11 + http_files = module:depends "http_files"; +end local app_config = module:get_option("site_apps", { { diff -r 807007913f67 -r 733e5513f691 mod_welcome_page/mod_welcome_page.lua --- a/mod_welcome_page/mod_welcome_page.lua Mon Jul 11 20:08:41 2022 +0200 +++ b/mod_welcome_page/mod_welcome_page.lua Mon Jul 18 13:58:27 2022 +0200 @@ -61,7 +61,14 @@ return 303; end -local http_files = module:depends("http_files"); +local http_files +if not pcall(function() + -- Prosody >= 0.12 + http_files = require "net.http.files"; +end) then + -- Prosody <= 0.11 + http_files = module:depends "http_files"; +end module:provides("http", { default_path = "/";