38 lines
818 B
Go
38 lines
818 B
Go
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))
|
|
}
|