LiveList.cs 986 B

12345678910111213141516171819202122232425262728293031
  1. using Web.Api.Common;
  2. using Web.Api.Extensions;
  3. using Application.Abstractions.Messaging;
  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. .RequireFeature(c => c.Channel);
  27. }
  28. }