diff --git a/router.go b/router.go index 0b29fab..80f8e0f 100644 --- a/router.go +++ b/router.go @@ -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) {