mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-19 14:12:01 +08:00
refactor(server): Set Gin to release mode and adjust route order
Set Gin to release mode for better performance and adjusted the route order to ensure specific routes are matched before catch-all routes.
This commit is contained in:
parent
1ab3cfd450
commit
5bd41a5edd
@ -80,6 +80,9 @@ func init() {
|
|||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner, 0x1B)
|
fmt.Printf("\n %c[1;32m%s%c[0m\n\n", 0x1B, banner, 0x1B)
|
||||||
|
|
||||||
|
// 设置 Gin 为发布模式
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
|
||||||
// 初始化 Gin 路由
|
// 初始化 Gin 路由
|
||||||
router = gin.New()
|
router = gin.New()
|
||||||
setupLogger()
|
setupLogger()
|
||||||
@ -109,9 +112,9 @@ func main() {
|
|||||||
|
|
||||||
listenAddress := config.Config.Host + ":" + config.Config.Port
|
listenAddress := config.Config.Host + ":" + config.Config.Port
|
||||||
|
|
||||||
// 设置路由
|
// 设置路由 - 注意顺序
|
||||||
router.GET("/healthz", handler.Healthz)
|
router.GET("/healthz", handler.Healthz) // 具体路由放在前面
|
||||||
router.Any("/*path", handler.Convert) // 使用 Any 来匹配所有方法
|
router.NoRoute(handler.Convert) // 使用 NoRoute 替代 /*path
|
||||||
|
|
||||||
// 设置服务器参数
|
// 设置服务器参数
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user