public static IOcelotBuilder WithReplaceHandler(this IOcelotBuilder builder) { if (!_withReplaceHandler) { builder .WithRouteExtensions(); builder.AddDelegatingHandler <ReplaceHandler>(); _withReplaceHandler = true; } return(builder); }
/// <summary> /// Add <see cref="PollyRetryBreakerHandler"/> to Ocelot. /// </summary> public static IOcelotBuilder AddPolly(this IOcelotBuilder ocelotBuilder) { var errorMapping = new Dictionary <Type, Func <Exception, Error> > { { typeof(TaskCanceledException), e => new RequestTimedOutError(e) }, { typeof(TimeoutRejectedException), e => new RequestTimedOutError(e) }, { typeof(BrokenCircuitException), e => new RequestTimedOutError(e) } }; ocelotBuilder .AddDelegatingHandler <PollyRetryBreakerHandler>() .Services.AddSingleton(errorMapping); return(ocelotBuilder); }
private void AddTransientGlobalDelegatingHandler <T>() where T : DelegatingHandler { _ocelotBuilder.AddDelegatingHandler <T>(true); }
private void AddDelegate(DelegatingHandler handler) { _ocelotBuilder.AddDelegatingHandler(() => handler); }