Merge pull request #597 from kiyonlin/invalid-method

💫 short the invalid method check
This commit is contained in:
fenny 2020-07-13 05:43:36 -04:00 committed by GitHub
commit 96d5286e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

2
ctx.go
View File

@ -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

View File

@ -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