Raw
 1package web
 2
 3import "net/http"
 4
 5func (k *Kit) AdminPages(base []Route, dashboard http.Handler, extra ...Route) []Route {
 6	if dashboard == nil {
 7		panic("web: the admin pages need a dashboard")
 8	}
 9	out := make([]Route, 0, len(base)+len(extra)+3)
10	for _, rt := range base {
11		switch {
12		case rt.Path != "/" || rt.Prefix:
13			out = append(out, rt)
14		case rt.Method != http.MethodGet:
15			panic("web: the admin pages own /, and the base declares " + rt.Method + " /")
16		}
17	}
18	out = append(out,
19		Route{Method: http.MethodGet, Path: "/", Handler: dashboard},
20	)
21	return append(out, extra...)
22}