LiveList.cs 919 B

123456789101112131415161718192021222324252627282930
  1. using Web.Api.Common;
  2. using Web.Api.Extensions;
  3. using MediatR;
  4. namespace Web.Api.Endpoints.Channel;
  5. /// <summary>라이브 방송 중인 채널 목록 (메인 페이지용, 페이지네이션 지원)</summary>
  6. internal sealed class LiveList : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/channel/live-list", async (
  11. ISender sender,
  12. CancellationToken ct,
  13. int limit = 24,
  14. int offset = 0,
  15. string? keyword = null,
  16. string? sort = null
  17. ) => {
  18. var result = await sender.Send(new Application.Features.Api.Channel.GetLiveList.Query(limit, offset, keyword, sort), ct);
  19. return result.Match(
  20. () => ApiResponse.Ok(result.Value),
  21. CustomResults.Problem
  22. );
  23. })
  24. .WithTags("Channel")
  25. .AllowAnonymous();
  26. }
  27. }