server.go 432 B

1234567891011121314151617181920212223
  1. package server
  2. import (
  3. "go-msa-auth/config"
  4. "go-msa-auth/internal/handlers"
  5. "go-msa-auth/internal/models"
  6. "github.com/gin-gonic/gin"
  7. )
  8. // InitServer 初始化服务器
  9. func InitServer() error {
  10. // 初始化数据库
  11. models.InitDatabase(config.AppConfig.DBPath)
  12. // 创建 Gin 实例
  13. r := gin.Default()
  14. // 路由配置
  15. r.POST("/auth", handlers.AuthHandler)
  16. // 启动服务
  17. return r.Run(config.AppConfig.ServerPort)
  18. }