Live video on the AT Protocol

Add getBlob endpoint to internal API for branding admin page.

authored by

Natalie Bridgers and committed by
Natalie B.
c0a8f46e bd360a35

+19
+14
pkg/api/api_internal.go
··· 473 473 } 474 474 }) 475 475 476 + router.GET("/xrpc/place.stream.branding.getBlob", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { 477 + // call XRPC handler directly instead of proxying 478 + key := r.URL.Query().Get("key") 479 + broadcasterDID := r.URL.Query().Get("broadcaster") 480 + reader, err := a.XRPCServer.HandlePlaceStreamBrandingGetBlobDirect(ctx, broadcasterDID, key) 481 + if err != nil { 482 + errors.WriteHTTPInternalServerError(w, "failed to fetch blob", err) 483 + return 484 + } 485 + if _, err := io.Copy(w, reader); err != nil { 486 + log.Error(ctx, "error writing response", "error", err) 487 + } 488 + }) 489 + 476 490 router.PUT("/branding/:key", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { 477 491 key := p.ByName("key") 478 492 if key == "" {
+5
pkg/spxrpc/place_stream_branding.go
··· 77 77 } 78 78 79 79 func (s *Server) handlePlaceStreamBrandingGetBlob(ctx context.Context, broadcasterDID string, key string) (io.Reader, error) { 80 + return s.HandlePlaceStreamBrandingGetBlobDirect(ctx, broadcasterDID, key) 81 + } 82 + 83 + // HandlePlaceStreamBrandingGetBlobDirect is the exported version for direct calls 84 + func (s *Server) HandlePlaceStreamBrandingGetBlobDirect(ctx context.Context, broadcasterDID string, key string) (io.Reader, error) { 80 85 broadcasterID := s.getBroadcasterID(ctx, broadcasterDID) 81 86 data, _, err := s.getBrandingBlobCached(ctx, broadcasterID, key) 82 87 if err != nil {