learnsteam-quiz-api/internal/routers/swagger.go

38 lines
818 B
Go
Raw Normal View History

2023-11-17 01:38:01 +09:00
package routers
import (
"learnsteam/learsteam-quiz-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(router)
}
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(router *gin.Engine) {
group := router.Group("/swagger")
group.GET("*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}