Add route working correctly, callbacks worked into method map.

This commit is contained in:
2020-09-01 19:16:08 -07:00
parent d240fa1b0c
commit a791b26248
2 changed files with 24 additions and 11 deletions

View File

@ -28,11 +28,23 @@ func TestAddRouter(t *testing.T) {
t.Error("The route was not correctly added to the router: ", err)
}
err = addAndCheckRoute(&r, http.MethodDelete, "/items/thing/man/bird/horse/poop", func(http.ResponseWriter, *http.Request) {}, &routeCounter)
if err != nil {
t.Error("The route was not correctly added to the router: ", err)
}
err = addAndCheckRoute(&r, http.MethodDelete, "/items/thing/man/bird/cat/poop", func(http.ResponseWriter, *http.Request) {}, &routeCounter)
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)
fmt.Printf("%p { path: %s, methods: %v, children: %v}\n", curr, curr.path, curr.methods, curr.children)
for _, v := range curr.children {
checkLookup(v)