package web import "net/http" func (k *Kit) AdminPages(base []Route, dashboard http.Handler, extra ...Route) []Route { if dashboard == nil { panic("web: the admin pages need a dashboard") } out := make([]Route, 0, len(base)+len(extra)+3) for _, rt := range base { switch { case rt.Path != "/" || rt.Prefix: out = append(out, rt) case rt.Method != http.MethodGet: panic("web: the admin pages own /, and the base declares " + rt.Method + " /") } } out = append(out, Route{Method: http.MethodGet, Path: "/", Handler: dashboard}, ) return append(out, extra...) }