CryptoTickers.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using MediatR;
  2. using Web.Api.Common;
  3. namespace Web.Api.Endpoints.Crypto;
  4. internal sealed class CryptoTickers : IEndpoint
  5. {
  6. public void MapEndpoint(IEndpointRouteBuilder app)
  7. {
  8. app.MapGet("api/crypto/tickers", async (
  9. ISender sender,
  10. CancellationToken ct
  11. ) =>
  12. {
  13. return ApiResponse.Ok(
  14. await sender.Send(new Application.Features.Api.Crypto.Ticker.GetAll.Query(false), ct)
  15. );
  16. })
  17. .WithTags("Crypto")
  18. .AllowAnonymous();
  19. app.MapGet("api/crypto/tickers/featured", async (
  20. ISender sender,
  21. CancellationToken ct
  22. ) =>
  23. {
  24. return ApiResponse.Ok(
  25. await sender.Send(new Application.Features.Api.Crypto.Ticker.GetAll.Query(true), ct)
  26. );
  27. })
  28. .WithTags("Crypto")
  29. .AllowAnonymous();
  30. app.MapGet("api/crypto/{symbol}/ticker", async (
  31. string symbol,
  32. ISender sender,
  33. CancellationToken ct
  34. ) =>
  35. {
  36. return ApiResponse.Ok(
  37. await sender.Send(new Application.Features.Api.Crypto.Ticker.GetDetail.Query(symbol), ct)
  38. );
  39. })
  40. .WithTags("Crypto")
  41. .AllowAnonymous();
  42. }
  43. }