github.com/angryronald/go-kit@v0.0.0-20240505173814-ff2bd9c79dbf/test/http/http.utils.go (about) 1 package http 2 3 import ( 4 "strings" 5 6 "github.com/go-chi/chi" 7 ) 8 9 // Helper function to check if a route exists in the chi router 10 func IsRouteExists(router *chi.Mux, routePattern string) bool { 11 // Iterate through the registered routes and check if the pattern matches 12 for _, route := range router.Routes() { 13 if strings.Contains(route.Pattern, routePattern) { 14 return true 15 } 16 if route.SubRoutes != nil { 17 for _, subroute := range route.SubRoutes.Routes() { 18 if strings.Contains(subroute.Pattern, routePattern) { 19 return true 20 } 21 } 22 } 23 } 24 return false 25 }