1234567891011121314151617181920212223242526 |
- package route
- import (
- "kpt-tmr-group/http/middleware"
- "github.com/gin-contrib/gzip"
- "github.com/gin-contrib/requestid"
- "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)
- }
- // common middleware
- s.Use(
- middleware.CORS(),
- middleware.Pagination(),
- requestid.New(),
- gzip.Gzip(gzip.DefaultCompression),
- gin.Recovery(),
- )
- }
- }
|