Skip to content

Commit c144dbd

Browse files
committed
swagger ui 显示支持可以配置
1 parent 94c99db commit c144dbd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pkg/config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func DefaultConfig() *Config {
5151
config.Port = 1233
5252
config.LogPath = "logs"
5353

54-
config.LogConfig.LogFile = "app.log"
54+
config.LogConfig.LogFile = "./logs/log-beetle.log"
5555
config.LogConfig.MaxSize = 1 // 默认值为 100 MB
5656
config.LogConfig.MaxBackups = 5 // 默认值为 10
5757
config.LogConfig.MaxAge = 30 // 默认值为 30 天

web/routers.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/gin-gonic/gin"
55
"github.com/reggiepy/LogBeetle/docs"
66
"github.com/reggiepy/LogBeetle/middleware"
7+
"github.com/reggiepy/LogBeetle/pkg/config"
78
"github.com/reggiepy/LogBeetle/pkg/logger"
89
"github.com/reggiepy/LogBeetle/web/api"
910
swaggerFiles "github.com/swaggo/files"
@@ -37,7 +38,11 @@ func SetupRouter() *gin.Engine {
3738
r.GET("/log-beetle/v1/ping", api.PingHandler)
3839
r.GET("/log-beetle/v1/about", api.AboutHandler)
3940
r.POST("/log-beetle/v1/send-message", api.SendMessageHandler)
40-
// use ginSwagger middleware to serve the API docs
41-
r.GET("/log-beetle/v1/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
41+
if config.Instance.Env == "dev" {
42+
// use ginSwagger middleware to serve the API docs
43+
r.GET("/log-beetle/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
44+
} else {
45+
gin.SetMode(gin.ReleaseMode)
46+
}
4247
return r
4348
}

0 commit comments

Comments
 (0)