2026-02-14 17:04:37 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
|
|
"veza-backend-api/internal/handlers"
|
|
|
|
|
"veza-backend-api/internal/repositories"
|
|
|
|
|
"veza-backend-api/internal/services"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// setupLiveRoutes configure les routes live streams
|
|
|
|
|
func (r *APIRouter) setupLiveRoutes(router *gin.RouterGroup) {
|
|
|
|
|
liveStreamRepo := repositories.NewLiveStreamRepository(r.db.GormDB)
|
feat(v0.703): Go Live & Streaming Complet
- Backend: room creation for live streams, permissions CanJoin/CanSend/CanRead for stream rooms
- LiveViewChat: useLiveStreamChat hook, WebSocket connection, stream_id as room
- LiveViewPlayer: real-time viewer count via polling (5s)
- Media Session: seekbackward/seekforward handlers (10s step)
- GoLiveView.stories.tsx: Default, Loading, Error, StreamKeyVisible
- Docs: API_REFERENCE, CHANGELOG, PROJECT_STATE, FEATURE_STATUS, RETROSPECTIVE_V0703
- SCOPE_CONTROL, .cursorrules: update to v0.801
- Archive V0_703_RELEASE_SCOPE.md
2026-02-25 08:35:22 +00:00
|
|
|
roomRepo := repositories.NewRoomRepository(r.db.GormDB)
|
|
|
|
|
liveStreamService := services.NewLiveStreamService(liveStreamRepo, roomRepo)
|
2026-02-14 17:04:37 +00:00
|
|
|
liveStreamHandler := handlers.NewLiveStreamHandler(liveStreamService, r.logger)
|
2026-03-10 09:21:57 +00:00
|
|
|
callbackHandler := handlers.NewLiveStreamCallbackHandler(liveStreamService, r.logger)
|
2026-02-14 17:04:37 +00:00
|
|
|
|
|
|
|
|
live := router.Group("/live")
|
|
|
|
|
{
|
2026-03-10 09:21:57 +00:00
|
|
|
// v0.10.6 F471: Nginx-RTMP callbacks (secret-protected, no auth)
|
|
|
|
|
live.POST("/callback/publish", callbackHandler.HandlePublish)
|
|
|
|
|
live.POST("/callback/publish_done", callbackHandler.HandlePublishDone)
|
2026-02-24 08:53:01 +00:00
|
|
|
// Protected routes (me/* MUST come before :id)
|
2026-02-14 17:04:37 +00:00
|
|
|
if r.config != nil && r.config.AuthMiddleware != nil {
|
|
|
|
|
protected := live.Group("")
|
|
|
|
|
protected.Use(r.config.AuthMiddleware.RequireAuth())
|
|
|
|
|
r.applyCSRFProtection(protected)
|
2026-02-24 08:53:01 +00:00
|
|
|
protected.GET("/streams/me", liveStreamHandler.GetMyStreams)
|
|
|
|
|
protected.GET("/streams/me/key", liveStreamHandler.GetMyStreamKey)
|
|
|
|
|
protected.POST("/streams/me/key/regenerate", liveStreamHandler.RegenerateStreamKey)
|
2026-02-14 17:04:37 +00:00
|
|
|
protected.POST("/streams", liveStreamHandler.CreateLiveStream)
|
2026-02-24 08:53:01 +00:00
|
|
|
protected.PUT("/streams/:id", liveStreamHandler.UpdateLiveStream)
|
2026-02-14 17:04:37 +00:00
|
|
|
}
|
2026-02-24 08:53:01 +00:00
|
|
|
// Public routes (after protected)
|
|
|
|
|
live.GET("/streams", liveStreamHandler.ListLiveStreams)
|
|
|
|
|
live.GET("/streams/:id", liveStreamHandler.GetLiveStream)
|
2026-02-14 17:04:37 +00:00
|
|
|
}
|
|
|
|
|
}
|