- Added chat history persistence for active rooms with auto-cleanup on stream end. - Overhauled Settings page with user profile, theme color picker, and password change. - Added backend API for user password updates. - Integrated flutter_launcher_icons and updated app icon to 'H' logo. - Fixed 'Duplicate keys' bug in danmaku by using UniqueKey and filtering historical messages. - Updated version to 1.0.0-beta3.5 and author info.
35 lines
796 B
Go
35 lines
796 B
Go
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)
|
|
|
|
// WebSocket endpoint for live chat
|
|
r.GET("/api/ws/room/:room_id", WSHandler)
|
|
|
|
// Protected routes (require JWT)
|
|
authGroup := r.Group("/api")
|
|
authGroup.Use(AuthMiddleware())
|
|
{
|
|
authGroup.GET("/room/my", GetMyRoom)
|
|
authGroup.POST("/user/change-password", ChangePassword)
|
|
}
|
|
|
|
return r
|
|
}
|