cslms-api/internal/routers/swagger.go
2023-12-27 17:31:49 +09:00

38 lines
787 B
Go

package routers
import (
"learnsteam/cslms-api/internal/controllers"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
func InitSwaggerRouter(router *gin.Engine) {
r := NewSwaggerRouter(router)
r.SetSwaggerRouter()
}
type SwaggerRouter interface {
SetRouter(router *gin.Engine)
}
type swaggerRouter struct {
router *gin.Engine
controller controllers.SwaggerController
}
func NewSwaggerRouter(router *gin.Engine) *swaggerRouter {
controller := controllers.NewSwaggerController()
return &swaggerRouter{
router: router,
controller: controller,
}
}
func (r *swaggerRouter) SetSwaggerRouter() {
group := r.router.Group("/swagger")
group.GET("*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}