From 5bd2f6e8d3e4504841c68f1cb153cffee5aba2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=BB=E5=AF=BB=E8=A7=85=E8=A7=85=E7=9A=84Gopher?= Date: Tue, 28 Sep 2021 09:45:50 +0800 Subject: [PATCH] turn on HandleMethodNotAllowed when using NoMethod #2871 (#2872) (cherry picked from commit d6534ccf3893b74738c78f51f8cb880c34db4ec6) --- gin.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gin.go b/gin.go index 03a0e127e6..9af932a304 100644 --- a/gin.go +++ b/gin.go @@ -249,8 +249,9 @@ func (engine *Engine) NoRoute(handlers ...HandlerFunc) { engine.rebuild404Handlers() } -// NoMethod sets the handlers called when... TODO. +// NoMethod sets the handlers called when NoMethod. func (engine *Engine) NoMethod(handlers ...HandlerFunc) { + engine.HandleMethodNotAllowed = true engine.noMethod = handlers engine.rebuild405Handlers() }