aboutsummaryrefslogtreecommitdiffhomepage
path: root/admin.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-08-21 10:46:35 -0600
committerMatthew Holt <[email protected]>2019-08-21 10:46:35 -0600
commitc9980fd3671d873a7197a5ac4d6ac9d6b046abb6 (patch)
tree75c301ab10590fb5f7d5b869a3424b8d46176bbf /admin.go
parentc4159ef76d279d6a84257b24dbe97430af32eb1e (diff)
downloadcaddy-c9980fd3671d873a7197a5ac4d6ac9d6b046abb6.tar.gz
caddy-c9980fd3671d873a7197a5ac4d6ac9d6b046abb6.zip
Refactor Caddyfile adapter and module registration
Use piles from which to draw config values. Module values can return their name, so now we can do two-way mapping from value to name and name to value; whereas before we could only map name to value. This was problematic with the Caddyfile adapter since it receives values and needs to know the name to put in the config.
Diffstat (limited to 'admin.go')
-rw-r--r--admin.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/admin.go b/admin.go
index ba3f06023..77999130e 100644
--- a/admin.go
+++ b/admin.go
@@ -95,9 +95,9 @@ func StartAdmin(initialConfigJSON []byte) error {
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
///// END PPROF STUFF //////
- for _, m := range GetModules("admin") {
- routes := m.New().([]AdminRoute)
- for _, route := range routes {
+ for _, m := range GetModules("admin.routers") {
+ adminrtr := m.New().(AdminRouter)
+ for _, route := range adminrtr.Routes() {
mux.Handle(route.Pattern, route)
}
}
@@ -146,6 +146,11 @@ func StopAdmin() error {
return nil
}
+// AdminRouter is a type which can return routes for the admin API.
+type AdminRouter interface {
+ Routes() []AdminRoute
+}
+
// AdminRoute represents a route for the admin endpoint.
type AdminRoute struct {
http.Handler