| 123456789101112131415161718192021222324252627282930313233 |
- using Application.Abstractions.Messaging;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Feed;
- internal sealed class ByTag : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapGet("api/feed/tag/{slug}", async (
- string slug,
- int? page,
- int? perPage,
- ISender sender,
- CancellationToken ct
- ) => {
- var query = new Application.Features.Api.Feed.GetByTag.Query(
- slug,
- page is > 0 ? page.Value : 1,
- (ushort)Math.Clamp(perPage ?? 20, 1, 50)
- );
- var result = await sender.Send(query, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("Feed");
- }
- }
|