This commit is contained in:
@@ -2,7 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"mrcc/internal/auth"
|
||||
"mrcc/internal/config"
|
||||
"mrcc/internal/httpserver"
|
||||
"mrcc/internal/logger"
|
||||
@@ -14,12 +16,25 @@ func main() {
|
||||
|
||||
srv := httpserver.New(cfg)
|
||||
|
||||
// TODO: 注册认证路由
|
||||
// r := srv.Group("/api/auth")
|
||||
// r.POST("/register", ...)
|
||||
// r.POST("/login", ...)
|
||||
// JWT 密钥:默认开发密钥,生产环境通过 AUTH_JWT_SECRET 覆盖
|
||||
secret := os.Getenv("AUTH_JWT_SECRET")
|
||||
if secret == "" {
|
||||
secret = "mrcc-dev-secret-change-me"
|
||||
}
|
||||
|
||||
log.Printf("auth-service listening on %s", cfg.Address())
|
||||
store := auth.NewUserStore()
|
||||
jwtMgr := auth.NewJWTManager(secret)
|
||||
h := auth.NewHandler(store, jwtMgr)
|
||||
|
||||
// 认证路由: /api/auth/register|login|me
|
||||
authGroup := srv.Group("/api/auth")
|
||||
h.RegisterAuthRoutes(authGroup)
|
||||
|
||||
// 经济路由: /api/daily-reward|spend|buy|use-item
|
||||
apiGroup := srv.Group("/api")
|
||||
h.RegisterEconomyRoutes(apiGroup)
|
||||
|
||||
log.Printf("auth-service listening on %s (endpoints: /api/auth/*, /api/daily-reward ...)", cfg.Address())
|
||||
if err := srv.Run(cfg.Address()); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user