private async Task <IActionResult> HandlePercolationResult(PercolationDto percolation, Func <Task <PercolationResult> > action) { var result = await action(); return(result switch { PercolationResult.Success => new ReversedProxyResult(percolation.Destination), PercolationResult.Failed => new ObjectResult(new ProblemDetails { Status = StatusCodes.Status202Accepted, Title = "Not reversed", Detail = "Request doesn't fit with filter and wasn't reversed to destination host" }), _ => throw new NotImplementedException("Not implemented percolation result"), });
public Task <IActionResult> PercolateByFilterAsync([FromRoute] Guid filterId, [FromQuery] PercolationDto percolation, CancellationToken cancellationToken) { return(HandlePercolationResult(percolation, () => percolationService.PercolateRequestAsync(Request, filterId, cancellationToken))); }