RotateSecret.cs 883 B

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