root.go 465 B

1234567891011121314151617181920212223242526
  1. package route
  2. import (
  3. "kpt-tmr-group/http/middleware"
  4. "github.com/gin-contrib/gzip"
  5. "github.com/gin-contrib/requestid"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func Root(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
  9. return func(s *gin.Engine) {
  10. for _, opt := range opts {
  11. opt(s)
  12. }
  13. // common middleware
  14. s.Use(
  15. middleware.CORS(),
  16. middleware.Pagination(),
  17. requestid.New(),
  18. gzip.Gzip(gzip.DefaultCompression),
  19. gin.Recovery(),
  20. )
  21. }
  22. }