Skip to content

Commit

Permalink
Merge pull request #629 from kiyonlin/reset-ctx-matched
Browse files Browse the repository at this point in the history
🔔 fix ctx matched bug
  • Loading branch information
Fenny authored Jul 17, 2020
2 parents 6fd1dd9 + c89bfb3 commit 531e50e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ func Test_App_MethodNotAllowed(t *testing.T) {

app.Options("/", func(c *Ctx) {})

resp, err := app.Test(httptest.NewRequest("GET", "/", nil))
resp, err := app.Test(httptest.NewRequest("POST", "/", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, "", resp.Header.Get(HeaderAllow))

resp, err = app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 405, resp.StatusCode)
utils.AssertEqual(t, "POST, OPTIONS", resp.Header.Get(HeaderAllow))
Expand Down
2 changes: 2 additions & 0 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (app *App) AcquireCtx(fctx *fasthttp.RequestCtx) *Ctx {
// Reset route and handler index
ctx.indexRoute = -1
ctx.indexHandler = 0
// Reset matched flag
ctx.matched = false
// Set paths
ctx.path = getString(fctx.URI().PathOriginal())
ctx.pathOriginal = ctx.path
Expand Down

1 comment on commit 531e50e

@Fenny
Copy link
Member Author

@Fenny Fenny commented on 531e50e Jul 17, 2020

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 531e50e Previous: 6fd1dd9 Ratio
Benchmark_Router_Handler_Unescape 12620 ns/op 18 B/op 1 allocs/op 1234 ns/op 16 B/op 1 allocs/op 10.23

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.