package routers import ( "tmr-watch/http/handle/group" "tmr-watch/middleware" "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" ) func Root(opts ...func(engine *gin.Engine)) func(s *gin.Engine) { return func(s *gin.Engine) { for _, opt := range opts { opt(s) } s.NoRoute(group.Handle404) // common middleware s.Use( middleware.CORS(), gzip.Gzip(gzip.DefaultCompression), middleware.Pagination(), middleware.GinLogger(), middleware.GinRecovery(true), ) } }