zero-contrib
zero-contrib copied to clipboard
gin.NewRouter() never execute SetNotAllowedHandler callback
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