zero-contrib icon indicating copy to clipboard operation
zero-contrib copied to clipboard

gin.NewRouter() never execute SetNotAllowedHandler callback

Open StoneHao opened this issue 3 years ago • 0 comments

r := gin.NewRouter() //r := router.NewRouter() r.SetNotAllowedHandler(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { fmt.Println("not allowed") })) r.SetNotFoundHandler(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { fmt.Println("not found") }))

ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf, rest.WithRouter(r))

// the SetNotAllowedHandler never execute , always execute SetNotFoundHandler // but when r := router.NewRouter() SetNotAllowedHandler will be call

StoneHao avatar May 11 '22 08:05 StoneHao