39 lines
920 B
Go
39 lines
920 B
Go
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)
|
||
}
|