Add AddRequiredRoutes method to Router

This commit is contained in:
some 2024-10-08 19:06:09 -04:00
parent 834de42a3f
commit 63f669f03f
Signed by: some
GPG Key ID: 65D0589220B9BFC8

View File

@ -24,10 +24,17 @@ func NewRouter(mux *http.ServeMux, requiredRoutes []string) (ro *Router) {
ServeMux: mux,
routes: make(map[Route]*server),
}
ro.AddRequiredRoutes(requiredRoutes)
return
}
func (ro *Router) AddRequiredRoutes(requiredRoutes []string) {
if requiredRoutes == nil {
return
}
for _, pattern := range requiredRoutes {
ro.routes[Route{pattern: pattern, required: true}] = &server{}
}
return
}
func (ro *Router) Register(pattern string, server *server) (err error) {