Get.cs 679 B

123456789101112131415161718192021222324252627
  1. using MediatR;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Forum.Comment;
  5. internal sealed class Get : IEndpoint
  6. {
  7. public void MapEndpoint(IEndpointRouteBuilder app)
  8. {
  9. app.MapGet("api/forum/comments/{id}", async (
  10. int id,
  11. ISender sender,
  12. CancellationToken ct
  13. ) =>
  14. {
  15. var result = await sender.Send(new Application.Features.Api.Forum.Comment.Get.Query(id), ct);
  16. return result.Match(
  17. data => ApiResponse.Ok(data),
  18. CustomResults.Problem
  19. );
  20. })
  21. .WithTags("Forum")
  22. .AllowAnonymous();
  23. }
  24. }