summaryrefslogtreecommitdiff
path: root/admin.go
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2019-08-21 11:28:03 -0600
committerGitHub <noreply@github.com>2019-08-21 11:28:03 -0600
commit0544f0266a11874efb305a46db762248e64bc62d (patch)
tree3e75e6f59047bb967c52915e1e75aee6ad67c0ea /admin.go
parent42f75a4ca94ef3fb5e15a74e5dc9ef8b4f1f0b39 (diff)
parentb2aa679c33f63ebec5bc1a21bca01f345dffebdd (diff)
Merge pull request #2699 from caddyserver/cfadapter
v2: Implement config adapters and WIP Caddyfile adapter
Diffstat (limited to 'admin.go')
-rw-r--r--admin.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/admin.go b/admin.go
index ba704e6..7799913 100644
--- a/admin.go
+++ b/admin.go
@@ -95,9 +95,11 @@ func StartAdmin(initialConfigJSON []byte) error {
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
///// END PPROF STUFF //////
- for _, m := range GetModules("admin") {
- route := m.New().(AdminRoute)
- mux.Handle(route.Pattern, route)
+ for _, m := range GetModules("admin.routers") {
+ adminrtr := m.New().(AdminRouter)
+ for _, route := range adminrtr.Routes() {
+ mux.Handle(route.Pattern, route)
+ }
}
handler := cors.Default().Handler(mux)
@@ -144,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