ProductsGet.cs 779 B

1234567891011121314151617181920212223242526
  1. using Web.Api.Common;
  2. using Application.Abstractions.Messaging;
  3. namespace Web.Api.Endpoints.Store;
  4. /// <summary>상점 — 상품 상세 (Frontend 사용자).</summary>
  5. internal sealed class ProductsGet : IEndpoint
  6. {
  7. public void MapEndpoint(IEndpointRouteBuilder app)
  8. {
  9. app.MapGet("api/store/products/{id:int}", async (
  10. int id,
  11. ISender sender,
  12. CancellationToken ct
  13. ) => {
  14. var result = await sender.Send(new Application.Features.Api.Store.Products.Get.Query(id), ct);
  15. if (result.IsFailure)
  16. {
  17. return CustomResults.Problem(result);
  18. }
  19. return ApiResponse.Ok(result.Value);
  20. })
  21. .WithTags("Store")
  22. .AllowAnonymous();
  23. }
  24. }