mirror of
https://github.com/gofiber/fiber.git
synced 2025-04-27 13:14:31 +00:00
Merge pull request #597 from kiyonlin/invalid-method
💫 short the invalid method check
This commit is contained in:
commit
96d5286e9d
2
ctx.go
2
ctx.go
@ -604,7 +604,7 @@ func (ctx *Ctx) Method(override ...string) string {
|
||||
if len(override) > 0 {
|
||||
method := utils.ToUpper(override[0])
|
||||
mINT := methodInt(method)
|
||||
if mINT == 0 && method != MethodGet {
|
||||
if mINT == -1 {
|
||||
return ctx.method
|
||||
}
|
||||
ctx.method = method
|
||||
|
@ -622,6 +622,9 @@ func Test_Ctx_Method(t *testing.T) {
|
||||
utils.AssertEqual(t, MethodGet, ctx.Method())
|
||||
ctx.Method(MethodPost)
|
||||
utils.AssertEqual(t, MethodPost, ctx.Method())
|
||||
|
||||
ctx.Method("MethodInvalid")
|
||||
utils.AssertEqual(t, MethodPost, ctx.Method())
|
||||
}
|
||||
|
||||
// go test -run Test_Ctx_MultipartForm
|
||||
|
Loading…
x
Reference in New Issue
Block a user