Detail.cs 801 B

123456789101112131415161718192021222324252627
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Stocks;
  5. /// <summary>종목 상세 — 마스터 + 최근 시세 (익명 열람)</summary>
  6. internal sealed class Detail : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/stocks/{code:regex(^\\d{{6}}$)}", async (
  11. string code,
  12. ISender sender,
  13. CancellationToken ct
  14. ) => {
  15. var result = await sender.Send(new Application.Features.Api.Stocks.GetDetail.Query(code), ct);
  16. return result.Match(
  17. () => ApiResponse.Ok(result.Value),
  18. CustomResults.Problem
  19. );
  20. })
  21. .WithTags("Stocks")
  22. .AllowAnonymous();
  23. }
  24. }