viper-app/internal/server/ext/ext_doc.go

27 lines
477 B
Go
Raw Normal View History

//go:build swag
package ext
import (
_ "demo-server/docs"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
)
func init() {
initEngQueue = append(initEngQueue, initDOC)
}
func initDOC(r *gin.Engine) {
const docPrefix = "/swagger"
// swagger
r.GET(docPrefix+"/*any", ginSwagger.WrapHandler(
swaggerFiles.Handler,
//ginSwagger.URL("/swagger/doc.json"),
))
r.GET(docPrefix, func(c *gin.Context) {
c.Redirect(301, docPrefix+"/index.html")
})
}