Skip to content

Commit

Permalink
chore(webapi): Remove custom purge request binding (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
oskogstad authored Jan 16, 2025
1 parent c29c5b4 commit a373257
Showing 1 changed file with 0 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public PurgeDialogEndpoint(ISender sender)
public override void Configure()
{
Post("dialogs/{dialogId}/actions/purge");
RequestBinder(new PurgeDialogRequestBinder());
Policies(AuthorizationPolicy.ServiceProvider);
Group<ServiceOwnerGroup>();

Expand Down Expand Up @@ -52,24 +51,3 @@ public sealed class PurgeDialogRequest
[FromHeader(headerName: Constants.IfMatch, isRequired: false, removeFromSchema: true)]
public Guid? IfMatchDialogRevision { get; init; }
}



// Custom request binder to avoid attempted automatic deserialization of the Request body if the content type is application/json
public sealed class PurgeDialogRequestBinder : IRequestBinder<PurgeDialogRequest>
{
public ValueTask<PurgeDialogRequest> BindAsync(BinderContext ctx, CancellationToken ct)
{
if (!Guid.TryParse(ctx.HttpContext.Request.RouteValues["dialogId"]?.ToString()!, out var dialogId))
return ValueTask.FromResult(new PurgeDialogRequest());

ctx.HttpContext.Request.Headers.TryGetValue(Constants.IfMatch, out var revisionHeader);
var revisionFound = Guid.TryParse(revisionHeader, out var revision);

return ValueTask.FromResult(new PurgeDialogRequest
{
DialogId = dialogId,
IfMatchDialogRevision = revisionFound ? revision : null
});
}
}

0 comments on commit a373257

Please sign in to comment.