添加文件: xy_sh/cmd/server/main.go

This commit is contained in:
renzhiyuan 2026-07-27 10:11:28 +08:00
parent 30b98f3771
commit 0a06bdbdf8
1 changed files with 30 additions and 0 deletions

30
xy_sh/cmd/server/main.go Normal file
View File

@ -0,0 +1,30 @@
package main
import (
"log"
"xy_sh/internal/config"
"xy_sh/internal/router"
"xy_sh/pkg/crypto"
"github.com/gofiber/fiber/v2"
)
func main() {
cfg := config.LoadConfig()
crypto.InitCrypto(cfg.SM3Salt, cfg.SM4Key)
app := fiber.New(fiber.Config{
AppName: "XY SH API Server",
ReadTimeout: cfg.ReadTimeout,
WriteTimeout: cfg.WriteTimeout,
})
router.SetupRoutes(app)
log.Printf("服务启动,监听端口: %s", cfg.ServerPort)
if err := app.Listen(":" + cfg.ServerPort); err != nil {
log.Fatalf("服务启动失败: %v", err)
}
}