fix: swagger doc

This commit is contained in:
naiba 2024-10-25 00:19:44 +08:00
parent eae12d8df2
commit fa9d02396b

View File

@ -15,11 +15,13 @@ import (
swaggerfiles "github.com/swaggo/files" swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
docs "github.com/naiba/nezha/cmd/dashboard/docs"
"github.com/naiba/nezha/model" "github.com/naiba/nezha/model"
"github.com/naiba/nezha/service/singleton" "github.com/naiba/nezha/service/singleton"
) )
func ServeWeb() http.Handler { func ServeWeb() http.Handler {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
r := gin.Default() r := gin.Default()
@ -28,6 +30,7 @@ func ServeWeb() http.Handler {
pprof.Register(r) pprof.Register(r)
} }
if singleton.Conf.Debug { if singleton.Conf.Debug {
log.Printf("NEZHA>> Swagger(%s) UI available at http://localhost:%d/swagger/index.html", docs.SwaggerInfo.Version, singleton.Conf.ListenPort)
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler)) r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
} }