Files
quyun-v2/backend/app/http/tenant_media/play.go

39 lines
920 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tenant_media
import (
"quyun/v2/app/services"
"quyun/v2/database/models"
"github.com/gofiber/fiber/v3"
log "github.com/sirupsen/logrus"
)
// media provides media play endpoints (token-based, no JWT required).
//
// @provider
type media struct{}
// play
//
// @Summary 媒体播放入口(短时效 token
// @Tags TenantMedia
// @Accept json
// @Produce json
// @Param tenantCode path string true "Tenant Code"
// @Param token query string true "Play token"
//
// @Router /t/:tenantCode/v1/media/play [get]
// @Bind tenant local key(tenant)
// @Bind token query
func (*media) play(ctx fiber.Ctx, tenant *models.Tenant, token string) error {
log.WithFields(log.Fields{
"tenant_id": tenant.ID,
}).Info("tenant_media.play")
location, err := services.MediaDelivery.ResolvePlayRedirect(ctx.Context(), tenant.ID, token)
if err != nil {
return err
}
return ctx.Redirect().To(location)
}