(WIP) AddRoute creates tree for looking up routes. Needs to be restructured.

This commit is contained in:
2020-08-30 21:38:13 -07:00
parent 574c73c88b
commit d240fa1b0c
2 changed files with 95 additions and 7 deletions

View File

@ -27,6 +27,16 @@ func TestAddRouter(t *testing.T) {
if err != nil {
t.Error("The route was not correctly added to the router: ", err)
}
checkLookup(r.lookup)
}
func checkLookup(curr *segment) {
fmt.Printf("%p { path: %s, methods: %v, children: %v, callback: %p }\n", curr, curr.path, curr.methods, curr.children, curr.callback)
for _, v := range curr.children {
checkLookup(v)
}
}
func addAndCheckRoute(r *Router, method string, path string, callback http.HandlerFunc, routeCounter *int) (err error) {