public InternalConfiguration Create(FileConfiguration fileConfiguration, List <Route> routes)
        {
            var serviceProviderConfiguration = _serviceProviderConfigCreator.Create(fileConfiguration.GlobalConfiguration);

            var lbOptions = _loadBalancerOptionsCreator.Create(fileConfiguration.GlobalConfiguration.LoadBalancerOptions);

            var qosOptions = _qosOptionsCreator.Create(fileConfiguration.GlobalConfiguration.QoSOptions);

            var httpHandlerOptions = _httpHandlerOptionsCreator.Create(fileConfiguration.GlobalConfiguration.HttpHandlerOptions);

            var adminPath = _adminPath != null ? _adminPath.Path : null;

            var version = _versionCreator.Create(fileConfiguration.GlobalConfiguration.DownstreamHttpVersion);

            return(new InternalConfiguration(routes,
                                             adminPath,
                                             serviceProviderConfiguration,
                                             fileConfiguration.GlobalConfiguration.RequestIdKey,
                                             lbOptions,
                                             fileConfiguration.GlobalConfiguration.DownstreamScheme,
                                             qosOptions,
                                             httpHandlerOptions,
                                             version
                                             ));
        }
Example #2
0
 private void WhenICreate()
 {
     _result = _creator.Create(_fileLoadBalancerOptions);
 }
Example #3
0
        private DownstreamReRoute SetUpDownstreamReRoute(FileReRoute fileReRoute, FileGlobalConfiguration globalConfiguration)
        {
            var fileReRouteOptions = _fileReRouteOptionsCreator.Create(fileReRoute);

            var requestIdKey = _requestIdKeyCreator.Create(fileReRoute, globalConfiguration);

            var reRouteKey = _reRouteKeyCreator.Create(fileReRoute);

            var upstreamTemplatePattern = _upstreamTemplatePatternCreator.Create(fileReRoute);

            var authOptionsForRoute = _authOptionsCreator.Create(fileReRoute);

            var claimsToHeaders = _claimsToThingCreator.Create(fileReRoute.AddHeadersToRequest);

            var claimsToClaims = _claimsToThingCreator.Create(fileReRoute.AddClaimsToRequest);

            var claimsToQueries = _claimsToThingCreator.Create(fileReRoute.AddQueriesToRequest);

            var qosOptions = _qosOptionsCreator.Create(fileReRoute.QoSOptions, fileReRoute.UpstreamPathTemplate, fileReRoute.UpstreamHttpMethod);

            var rateLimitOption = _rateLimitOptionsCreator.Create(fileReRoute.RateLimitOptions, globalConfiguration);

            var region = _regionCreator.Create(fileReRoute);

            var httpHandlerOptions = _httpHandlerOptionsCreator.Create(fileReRoute.HttpHandlerOptions);

            var hAndRs = _headerFAndRCreator.Create(fileReRoute);

            var downstreamAddresses = _downstreamAddressesCreator.Create(fileReRoute);

            var lbOptions = _loadBalancerOptionsCreator.Create(fileReRoute.LoadBalancerOptions);

            var securityOptions = _securityOptionsCreator.Create(fileReRoute.SecurityOptions);

            var reRoute = new DownstreamReRouteBuilder()
                          .WithKey(fileReRoute.Key)
                          .WithDownstreamPathTemplate(fileReRoute.DownstreamPathTemplate)
                          .WithUpstreamHttpMethod(fileReRoute.UpstreamHttpMethod)
                          .WithUpstreamPathTemplate(upstreamTemplatePattern)
                          .WithIsAuthenticated(fileReRouteOptions.IsAuthenticated)
                          .WithAuthenticationOptions(authOptionsForRoute)
                          .WithClaimsToHeaders(claimsToHeaders)
                          .WithClaimsToClaims(claimsToClaims)
                          .WithRouteClaimsRequirement(fileReRoute.RouteClaimsRequirement)
                          .WithIsAuthorised(fileReRouteOptions.IsAuthorised)
                          .WithClaimsToQueries(claimsToQueries)
                          .WithRequestIdKey(requestIdKey)
                          .WithIsCached(fileReRouteOptions.IsCached)
                          .WithCacheOptions(new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds, region))
                          .WithDownstreamScheme(fileReRoute.DownstreamScheme)
                          .WithLoadBalancerOptions(lbOptions)
                          .WithDownstreamAddresses(downstreamAddresses)
                          .WithLoadBalancerKey(reRouteKey)
                          .WithQosOptions(qosOptions)
                          .WithEnableRateLimiting(fileReRouteOptions.EnableRateLimiting)
                          .WithRateLimitOptions(rateLimitOption)
                          .WithHttpHandlerOptions(httpHandlerOptions)
                          .WithServiceName(fileReRoute.ServiceName)
                          .WithUseServiceDiscovery(fileReRouteOptions.UseServiceDiscovery)
                          .WithUpstreamHeaderFindAndReplace(hAndRs.Upstream)
                          .WithDownstreamHeaderFindAndReplace(hAndRs.Downstream)
                          .WithDelegatingHandlers(fileReRoute.DelegatingHandlers)
                          .WithAddHeadersToDownstream(hAndRs.AddHeadersToDownstream)
                          .WithAddHeadersToUpstream(hAndRs.AddHeadersToUpstream)
                          .WithDangerousAcceptAnyServerCertificateValidator(fileReRoute.DangerousAcceptAnyServerCertificateValidator)
                          .WithSecurityOptions(securityOptions)
                          .Build();

            return(reRoute);
        }