Revoke.cs 867 B

12345678910111213141516171819202122232425262728
  1. using MediatR;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Developers.Tokens;
  5. internal sealed class Revoke : IEndpoint
  6. {
  7. public void MapEndpoint(IEndpointRouteBuilder app)
  8. {
  9. app.MapDelete("api/developers/tokens/{patID:long}", async (
  10. long patID,
  11. HttpContext httpContext,
  12. ISender sender,
  13. CancellationToken ct
  14. ) => {
  15. var memberID = httpContext.User.GetRequiredMemberID();
  16. var command = new Application.Features.Api.Developers.Tokens.RevokePat.Command(memberID, patID);
  17. var result = await sender.Send(command, ct);
  18. return result.Match(
  19. () => Results.NoContent(),
  20. CustomResults.Problem
  21. );
  22. })
  23. .WithTags("Developers")
  24. .RequireAuthorization();
  25. }
  26. }