Skip to content

Commit

Permalink
demonstrate static priority over wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
mar1n3r0 committed Jan 27, 2020
1 parent 6d709b5 commit 1cc5ab9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fasthttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,22 +391,24 @@ func TestFastHTTPNodeApplyMiddleware(t *testing.T) {
}
})

router.USE(http.MethodGet, "/x/{param}", mockFastHTTPMiddleware("m1"))
router.USE(http.MethodGet, "/x/x", mockFastHTTPMiddleware("m2"))
router.USE(http.MethodGet, "/x/x", mockFastHTTPMiddleware("m1"))
router.USE(http.MethodGet, "/x/{param}", mockFastHTTPMiddleware("m2"))
router.USE(http.MethodGet, "/x/x", mockFastHTTPMiddleware("m3"))
router.USE(http.MethodGet, "/x/{param}", mockFastHTTPMiddleware("m4"))

ctx := buildFastHTTPRequestContext(http.MethodGet, "/x/y")

router.HandleFastHTTP(ctx)

if string(ctx.Response.Body()) != "m1y" {
if string(ctx.Response.Body()) != "m2m4y" {
t.Errorf("Use globalMiddleware error %s", string(ctx.Response.Body()))
}

ctx = buildFastHTTPRequestContext(http.MethodGet, "/x/x")

router.HandleFastHTTP(ctx)

if string(ctx.Response.Body()) != "m1m2x" {
if string(ctx.Response.Body()) != "m1m2m3m4x" {
t.Errorf("Use globalMiddleware error %s", string(ctx.Response.Body()))
}
}
Expand Down Expand Up @@ -439,7 +441,7 @@ func TestFastHTTPTreeOrphanMiddlewareOrder(t *testing.T) {

router.HandleFastHTTP(ctx)

if string(ctx.Response.Body()) != "m1->m2->mx1->mx2->mxy1->mxy2->mxy3->mxy4->mparam1->mparam2->handler" {
if string(ctx.Response.Body()) != "m1->m2->mx1->mx2->mxy1->mxy2->mparam1->mparam2->mxy3->mxy4->handler" {
t.Errorf("Use globalMiddleware error %s", string(ctx.Response.Body()))
}
}
Expand Down

1 comment on commit 1cc5ab9

@vardius
Copy link
Owner

@vardius vardius commented on 1cc5ab9 Jan 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add one you have to do it for both router implementation.

Please sign in to comment.