public async Task <PipelineResponse> Handle(PizzaPipelineContext context, CancellationToken cancellationToken, RequestHandlerDelegate <PipelineResponse> nextFilter) { context.CurrentStep = nameof(ValidationFilter); if (context.Request.Values.Contains("continue")) { // SIMULATE: Validation succeeded, call next step _logger.LogInformation("Validation succeeded"); var result = string.Concat(context.Request.Values, " | Validation Signature | "); context.Request.Values = result; var pipelineResponse = await nextFilter.Invoke(); return(pipelineResponse); } // SIMULATE: Validation failed, short circuit and return an error response var pipelineError = new PipelineError { OcurredAtStep = nameof(ValidationFilter), Message = "Validation failed" }; var response = new PipelineResponse(string.Empty, pipelineError); return(response); }
public async Task <PipelineResponse> Handle(PizzaPipelineContext context, CancellationToken cancellationToken, RequestHandlerDelegate <PipelineResponse> nextFilter) { context.CurrentStep = nameof(MakePizzaCrustFilter); if (_fakeCounter % 4 == 0) { _fakeCounter++; throw new Exception("Boom"); } if (context.Request.Values.Contains("continue")) { _logger.LogInformation("Setting pizza base"); context.SetPizzaBase(PizzaBaseFlourType.Wheat, PizzaBaseType.Pan); _fakeCounter++; return(await nextFilter.Invoke()); } // SIMULATE: Validation failed, short circuit and return an error response var pipelineError = new PipelineError { OcurredAtStep = nameof(MakePizzaCrustFilter), Message = "Validation failed" }; var response = new PipelineResponse(string.Empty, pipelineError); _fakeCounter++; return(response); }