feat: 添加媒体播放功能,支持基于短时效token的播放入口及相关API接口
This commit is contained in:
38
backend/app/http/tenant_media/play.go
Normal file
38
backend/app/http/tenant_media/play.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user