public DelegatingHandlerHandlerProviderFactory(IOcelotLoggerFactory loggerFactory, IDelegatingHandlerHandlerProvider allRoutesProvider, ITracingHandlerFactory factory, IQosProviderHouse qosProviderHouse) { _factory = factory; _loggerFactory = loggerFactory; _allRoutesProvider = allRoutesProvider; _qosProviderHouse = qosProviderHouse; }
private void WhenIGet() { _provider = _factory.Get(_request); }
public OcelotBuilder(IServiceCollection services, IConfiguration configurationRoot) { _configurationRoot = configurationRoot; _services = services; //add default cache settings... Action <ConfigurationBuilderCachePart> defaultCachingSettings = x => { x.WithDictionaryHandle(); }; AddCacheManager(defaultCachingSettings); //add ocelot services... _services.Configure <FileConfiguration>(configurationRoot); _services.TryAddSingleton <IHttpResponseHeaderReplacer, HttpResponseHeaderReplacer>(); _services.TryAddSingleton <IHttpContextRequestHeaderReplacer, HttpContextRequestHeaderReplacer>(); _services.TryAddSingleton <IHeaderFindAndReplaceCreator, HeaderFindAndReplaceCreator>(); _services.TryAddSingleton <IOcelotConfigurationCreator, FileOcelotConfigurationCreator>(); _services.TryAddSingleton <IOcelotConfigurationRepository, InMemoryOcelotConfigurationRepository>(); _services.TryAddSingleton <IConfigurationValidator, FileConfigurationFluentValidator>(); _services.TryAddSingleton <IClaimsToThingCreator, ClaimsToThingCreator>(); _services.TryAddSingleton <IAuthenticationOptionsCreator, AuthenticationOptionsCreator>(); _services.TryAddSingleton <IUpstreamTemplatePatternCreator, UpstreamTemplatePatternCreator>(); _services.TryAddSingleton <IRequestIdKeyCreator, RequestIdKeyCreator>(); _services.TryAddSingleton <IServiceProviderConfigurationCreator, ServiceProviderConfigurationCreator>(); _services.TryAddSingleton <IQoSOptionsCreator, QoSOptionsCreator>(); _services.TryAddSingleton <IReRouteOptionsCreator, ReRouteOptionsCreator>(); _services.TryAddSingleton <IRateLimitOptionsCreator, RateLimitOptionsCreator>(); _services.TryAddSingleton <IBaseUrlFinder, BaseUrlFinder>(); _services.TryAddSingleton <IRegionCreator, RegionCreator>(); _services.TryAddSingleton <IFileConfigurationRepository, FileConfigurationRepository>(); _services.TryAddSingleton <IFileConfigurationSetter, FileConfigurationSetter>(); _services.TryAddSingleton <IFileConfigurationProvider, FileConfigurationProvider>(); _services.TryAddSingleton <IQosProviderHouse, QosProviderHouse>(); _services.TryAddSingleton <IQoSProviderFactory, QoSProviderFactory>(); _services.TryAddSingleton <IServiceDiscoveryProviderFactory, ServiceDiscoveryProviderFactory>(); _services.TryAddSingleton <ILoadBalancerFactory, LoadBalancerFactory>(); _services.TryAddSingleton <ILoadBalancerHouse, LoadBalancerHouse>(); _services.TryAddSingleton <IOcelotLoggerFactory, AspDotNetLoggerFactory>(); _services.TryAddSingleton <IUrlBuilder, UrlBuilder>(); _services.TryAddSingleton <IRemoveOutputHeaders, RemoveOutputHeaders>(); _services.TryAddSingleton <IOcelotConfigurationProvider, OcelotConfigurationProvider>(); _services.TryAddSingleton <IClaimToThingConfigurationParser, ClaimToThingConfigurationParser>(); _services.TryAddSingleton <IClaimsAuthoriser, ClaimsAuthoriser>(); _services.TryAddSingleton <IScopesAuthoriser, ScopesAuthoriser>(); _services.TryAddSingleton <IAddClaimsToRequest, AddClaimsToRequest>(); _services.TryAddSingleton <IAddHeadersToRequest, AddHeadersToRequest>(); _services.TryAddSingleton <IAddQueriesToRequest, AddQueriesToRequest>(); _services.TryAddSingleton <IClaimsParser, ClaimsParser>(); _services.TryAddSingleton <IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>(); _services.TryAddSingleton <IPlaceholderNameAndValueFinder, UrlPathPlaceholderNameAndValueFinder>(); _services.TryAddSingleton <IDownstreamPathPlaceholderReplacer, DownstreamTemplatePathPlaceholderReplacer>(); _services.TryAddSingleton <IDownstreamRouteFinder, DownstreamRouteFinder>(); _services.TryAddSingleton <IHttpRequester, HttpClientHttpRequester>(); _services.TryAddSingleton <IHttpResponder, HttpContextResponder>(); _services.TryAddSingleton <IErrorsToHttpStatusCodeMapper, ErrorsToHttpStatusCodeMapper>(); _services.TryAddSingleton <IRateLimitCounterHandler, MemoryCacheRateLimitCounterHandler>(); _services.TryAddSingleton <IHttpClientCache, MemoryHttpClientCache>(); _services.TryAddSingleton <IRequestMapper, RequestMapper>(); _services.TryAddSingleton <IHttpHandlerOptionsCreator, HttpHandlerOptionsCreator>(); _services.TryAddSingleton <IDownstreamAddressesCreator, DownstreamAddressesCreator>(); _services.TryAddSingleton <IDelegatingHandlerHandlerProviderFactory, DelegatingHandlerHandlerProviderFactory>(); _services.TryAddSingleton <IDelegatingHandlerHandlerHouse, DelegatingHandlerHandlerHouse>(); // see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc // could maybe use a scoped data repository _services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); _services.TryAddSingleton <IRequestScopedDataRepository, HttpDataRepository>(); _services.AddMemoryCache(); _services.TryAddSingleton <OcelotDiagnosticListener>(); //add asp.net services.. var assembly = typeof(FileConfigurationController).GetTypeInfo().Assembly; _services.AddMvcCore() .AddApplicationPart(assembly) .AddControllersAsServices() .AddAuthorization() .AddJsonFormatters(); _services.AddLogging(); _services.AddMiddlewareAnalysis(); _services.AddWebEncoders(); _services.AddSingleton <IAdministrationPath>(new NullAdministrationPath()); //these get picked out later and added to http request _provider = new DelegatingHandlerHandlerProvider(); _services.TryAddSingleton <IDelegatingHandlerHandlerProvider>(_provider); _services.TryAddSingleton <IMultiplexer, Multiplexer>(); _services.TryAddSingleton <IResponseAggregator, SimpleJsonResponseAggregator>(); _services.AddSingleton <ITracingHandlerFactory, TracingHandlerFactory>(); // We add this here so that we can always inject something into the factory for IoC.. _services.AddSingleton <IServiceTracer, FakeServiceTracer>(); }
public DelegatingHandlerHandlerProviderFactory(IOcelotLoggerFactory loggerFactory, IDelegatingHandlerHandlerProvider allRoutesProvider, ITracingHandler tracingHandler) { _tracingHandler = tracingHandler; _loggerFactory = loggerFactory; _allRoutesProvider = allRoutesProvider; }
private void AddHoused(string key, IDelegatingHandlerHandlerProvider provider) { _housed.AddOrUpdate(key, provider, (k, v) => provider); }