Use request contex

This commit is contained in:
2020-12-09 22:34:43 -08:00
parent 08228b2aa7
commit df7e3ccc03
2 changed files with 44 additions and 53 deletions

View File

@ -85,8 +85,8 @@ func checkLookup(curr *segment) {
checkLookup(v)
}
if curr.parameter != nil {
checkLookup(curr.parameter)
if curr.parameter.segment != nil {
checkLookup(curr.parameter.segment)
}
}
@ -246,14 +246,7 @@ func testParamValues(router Router, t *testing.T) {
reqPath := fmt.Sprintf("/users/%s/edit/%s", userID, status)
router.AddRoute(method, path, func(w http.ResponseWriter, r *http.Request) {
requestPath := r.URL.Path
requestMethod := r.Method
params, err := router.PathParams(requestMethod, requestPath)
if err != nil {
t.Error("An error occurred while getting path parameters")
}
params := router.PathParams(r)
if len(params) != 2 {
t.Errorf("Received the wrong number of parameters. Expected 2, recieved %d", len(params))