Пример #1
0
        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
                                             ));
        }
Пример #2
0
        private ReRoute SetUpDynamicReRoute(FileDynamicReRoute fileDynamicReRoute, FileGlobalConfiguration globalConfiguration)
        {
            var rateLimitOption = _rateLimitOptionsCreator
                                  .Create(fileDynamicReRoute.RateLimitRule, globalConfiguration);

            var version = _versionCreator.Create(fileDynamicReRoute.DownstreamHttpVersion);

            var downstreamReRoute = new DownstreamReRouteBuilder()
                                    .WithEnableRateLimiting(rateLimitOption.EnableRateLimiting)
                                    .WithRateLimitOptions(rateLimitOption)
                                    .WithServiceName(fileDynamicReRoute.ServiceName)
                                    .WithDownstreamHttpVersion(version)
                                    .Build();

            var reRoute = new ReRouteBuilder()
                          .WithDownstreamReRoute(downstreamReRoute)
                          .Build();

            return(reRoute);
        }
Пример #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 claimsToDownstreamPath = _claimsToThingCreator.Create(fileReRoute.ChangeDownstreamPathTemplate);

            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 downstreamHttpVersion = _versionCreator.Create(fileReRoute.DownstreamHttpVersion);

            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)
                          .WithClaimsToDownstreamPath(claimsToDownstreamPath)
                          .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)
                          .WithServiceNamespace(fileReRoute.ServiceNamespace)
                          .WithUseServiceDiscovery(fileReRouteOptions.UseServiceDiscovery)
                          .WithUpstreamHeaderFindAndReplace(hAndRs.Upstream)
                          .WithDownstreamHeaderFindAndReplace(hAndRs.Downstream)
                          .WithDelegatingHandlers(fileReRoute.DelegatingHandlers)
                          .WithAddHeadersToDownstream(hAndRs.AddHeadersToDownstream)
                          .WithAddHeadersToUpstream(hAndRs.AddHeadersToUpstream)
                          .WithDangerousAcceptAnyServerCertificateValidator(fileReRoute.DangerousAcceptAnyServerCertificateValidator)
                          .WithSecurityOptions(securityOptions)
                          .WithDownstreamHttpVersion(downstreamHttpVersion)
                          .WithDownStreamHttpMethod(fileReRoute.DownstreamHttpMethod)
                          .Build();

            return(reRoute);
        }