package handlers import ( "encoding/json" "net/http" "aroll/transcode" "aroll/ws" ) type zoomRequest struct { Zoom float64 `json:"zoom"` // 1–100, percentage of total duration to show Center float64 `json:"center"` // scroll center in seconds Duration float64 `json:"duration"` // total video duration in seconds } func ZoomHandler(hub *ws.Hub) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } var req zoomRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, "bad JSON: "+err.Error(), http.StatusBadRequest) return } result := transcode.TimelineZoom(req.Center, req.Zoom, req.Duration) data, _ := json.Marshal(result) hub.Broadcast(data) w.WriteHeader(http.StatusAccepted) } }