mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 15:53:17 +00:00
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.
This commit is contained in:
parent
c4159ef76d
commit
c9980fd367
46 changed files with 1512 additions and 1105 deletions
11
admin.go
11
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue