feat: swagger
This commit is contained in:
+15
-2
@@ -2,11 +2,15 @@ package initialize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"sundynix-go/docs"
|
||||
"sundynix-go/global"
|
||||
"sundynix-go/middleware"
|
||||
"sundynix-go/router"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Routers 初始化总路由
|
||||
@@ -17,6 +21,8 @@ func Routers() {
|
||||
if gin.Mode() == gin.DebugMode {
|
||||
Router.Use(gin.Logger())
|
||||
}
|
||||
docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
|
||||
Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
// 系统组路由
|
||||
systemRouter := router.GroupApp.System
|
||||
@@ -41,6 +47,13 @@ func Routers() {
|
||||
}
|
||||
|
||||
address := fmt.Sprintf(":%d", global.Config.System.Addr)
|
||||
fmt.Printf(`
|
||||
欢迎使用 sundynix-go
|
||||
项目地址:
|
||||
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
|
||||
默认前端文件运行地址:http://127.0.0.1:8080
|
||||
`, address)
|
||||
|
||||
err := Router.Run(address)
|
||||
if err != nil {
|
||||
global.Logger.Error("Gin run failed", zap.Error(err))
|
||||
|
||||
Reference in New Issue
Block a user