Phase 2 completed: Stream Server Auth, Database and Business API

This commit is contained in:
2026-03-16 15:54:41 +08:00
commit c84dd6ea36
16 changed files with 757 additions and 0 deletions

30
internal/api/router.go Normal file
View File

@@ -0,0 +1,30 @@
package api
import (
"github.com/gin-gonic/gin"
)
// SetupRouter configures the Gin router and defines API endpoints
func SetupRouter() *gin.Engine {
// 设置为发布模式,消除 "[WARNING] Running in debug mode" 警告
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
// 清除代理信任警告 "[WARNING] You trusted all proxies"
r.SetTrustedProxies(nil)
// Public routes
r.POST("/api/register", Register)
r.POST("/api/login", Login)
r.GET("/api/rooms/active", GetActiveRooms)
// Protected routes (require JWT)
authGroup := r.Group("/api")
authGroup.Use(AuthMiddleware())
{
authGroup.GET("/room/my", GetMyRoom)
}
return r
}