Software / code / prosody
Comparison
plugins/mod_admin_shell.lua @ 11361:dab1a6e46087
mod_admin_shell: List global HTTP endpoints by default
Trick copied from the module commands
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 03 Feb 2021 23:28:02 +0100 |
| parent | 11042:8a243ab49cb5 |
| child | 11362:52d93fba2ee1 |
comparison
equal
deleted
inserted
replaced
| 11360:f36a2e54ac81 | 11361:dab1a6e46087 |
|---|---|
| 1222 | 1222 |
| 1223 def_env.http = {}; | 1223 def_env.http = {}; |
| 1224 | 1224 |
| 1225 function def_env.http:list(hosts) | 1225 function def_env.http:list(hosts) |
| 1226 local print = self.session.print; | 1226 local print = self.session.print; |
| 1227 | 1227 hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts); |
| 1228 for host in get_hosts_set(hosts) do | 1228 |
| 1229 for _, host in ipairs(hosts) do | |
| 1229 local http_apps = modulemanager.get_items("http-provider", host); | 1230 local http_apps = modulemanager.get_items("http-provider", host); |
| 1230 if #http_apps > 0 then | 1231 if #http_apps > 0 then |
| 1231 local http_host = module:context(host):get_option_string("http_host"); | 1232 local http_host = module:context(host):get_option_string("http_host"); |
| 1232 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); | 1233 if host == "*" then |
| 1234 print("Global HTTP endpoints available on all hosts:"); | |
| 1235 else | |
| 1236 print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":")); | |
| 1237 end | |
| 1233 for _, provider in ipairs(http_apps) do | 1238 for _, provider in ipairs(http_apps) do |
| 1234 local url = module:context(host):http_url(provider.name, provider.default_path); | 1239 local url = module:context(host):http_url(provider.name, provider.default_path); |
| 1235 print("", url); | 1240 print("", url); |
| 1236 end | 1241 end |
| 1237 print(""); | 1242 print(""); |