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