From 63f669f03f75eb500d39d12da16d356d5a076a1e Mon Sep 17 00:00:00 2001 From: some Date: Tue, 8 Oct 2024 19:06:09 -0400 Subject: [PATCH] Add AddRequiredRoutes method to Router --- router.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) {