mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-31 11:52:41 +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 {
|
if len(override) > 0 {
|
||||||
method := utils.ToUpper(override[0])
|
method := utils.ToUpper(override[0])
|
||||||
mINT := methodInt(method)
|
mINT := methodInt(method)
|
||||||
if mINT == 0 && method != MethodGet {
|
if mINT == -1 {
|
||||||
return ctx.method
|
return ctx.method
|
||||||
}
|
}
|
||||||
ctx.method = method
|
ctx.method = method
|
||||||
|
@ -622,6 +622,9 @@ func Test_Ctx_Method(t *testing.T) {
|
|||||||
utils.AssertEqual(t, MethodGet, ctx.Method())
|
utils.AssertEqual(t, MethodGet, ctx.Method())
|
||||||
ctx.Method(MethodPost)
|
ctx.Method(MethodPost)
|
||||||
utils.AssertEqual(t, MethodPost, ctx.Method())
|
utils.AssertEqual(t, MethodPost, ctx.Method())
|
||||||
|
|
||||||
|
ctx.Method("MethodInvalid")
|
||||||
|
utils.AssertEqual(t, MethodPost, ctx.Method())
|
||||||
}
|
}
|
||||||
|
|
||||||
// go test -run Test_Ctx_MultipartForm
|
// go test -run Test_Ctx_MultipartForm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user