Comparison

plugins/mod_admin_shell.lua @ 13117:7eb6244b4984

mod_admin_shell: Show internal URL where different from external
author Kim Alvefur <zash@zash.se>
date Sun, 28 May 2023 22:33:45 +0200
parent 13108:6cd768e6ac7c
child 13128:38582771b593
comparison
equal deleted inserted replaced
13116:58e793288d9c 13117:7eb6244b4984
1834 def_env.http = {}; 1834 def_env.http = {};
1835 1835
1836 function def_env.http:list(hosts) 1836 function def_env.http:list(hosts)
1837 local print = self.session.print; 1837 local print = self.session.print;
1838 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); 1838 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts);
1839 local output = format_table({ 1839 local output_simple = format_table({
1840 { title = "Module"; width = "1p" }; 1840 { title = "Module"; width = "1p" };
1841 { title = "URL"; width = "3p" }; 1841 { title = "External URL"; width = "6p" };
1842 }, self.session.width);
1843 local output_split = format_table({
1844 { title = "Module"; width = "1p" };
1845 { title = "External URL"; width = "3p" };
1842 { title = "Internal URL"; width = "3p" }; 1846 { title = "Internal URL"; width = "3p" };
1843 }, self.session.width); 1847 }, self.session.width);
1844 1848
1845 for _, host in ipairs(hosts) do 1849 for _, host in ipairs(hosts) do
1846 local http_apps = modulemanager.get_items("http-provider", host); 1850 local http_apps = modulemanager.get_items("http-provider", host);
1849 if host == "*" then 1853 if host == "*" then
1850 print("Global HTTP endpoints available on all hosts:"); 1854 print("Global HTTP endpoints available on all hosts:");
1851 else 1855 else
1852 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); 1856 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":"));
1853 end 1857 end
1854 print(output()); 1858 print(output_split());
1855 for _, provider in ipairs(http_apps) do 1859 for _, provider in ipairs(http_apps) do
1856 local mod = provider._provided_by; 1860 local mod = provider._provided_by;
1857 local external = module:context(host):http_url(provider.name, provider.default_path); 1861 local external = module:context(host):http_url(provider.name, provider.default_path);
1858 local internal = module:context(host):http_url(provider.name, provider.default_path, "internal"); 1862 local internal = module:context(host):http_url(provider.name, provider.default_path, "internal");
1859 if external==internal then internal="" end 1863 if external==internal then internal="" end
1860 mod = mod and "mod_"..mod or "" 1864 mod = mod and "mod_"..mod or ""
1861 print(output{mod, external, internal}); 1865 print((internal=="" and output_simple or output_split){mod, external, internal});
1862 end 1866 end
1863 print(""); 1867 print("");
1864 end 1868 end
1865 end 1869 end
1866 1870