示例#1
0
        public virtual void AddReRoutes(string name,
                                        string upstreamPathTemplate,
                                        string upstreamHost,
                                        string downstreamScheme,
                                        string downstreamPathTemplate,
                                        List <string> upstreamHttpMethods = null,
                                        Dictionary <string, int> downstreamHostAndPorts = null)
        {
            var reRoute = new OcelotReRoute(
                Id,
                name,
                upstreamPathTemplate,
                upstreamHost,
                downstreamScheme,
                downstreamPathTemplate
                );

            if (upstreamHttpMethods != null)
            {
                foreach (var item in upstreamHttpMethods)
                {
                    reRoute.AddUpstreamHttpMethod(item);
                }
            }
            if (downstreamHostAndPorts != null)
            {
                foreach (var item in downstreamHostAndPorts)
                {
                    reRoute.AddDownstreamHostAndPort(item.Key, item.Value);
                }
            }

            ReRoutes.Add(reRoute);
        }
示例#2
0
        public List <string> Resolve(OcelotReRoute source, OcelotReRouteDto destination, List <string> destMember, ResolutionContext context)
        {
            if (source == null || source.DelegatingHandlers == null)
            {
                return(null);
            }

            return(source.DelegatingHandlers.Select(c => c.Delegating).ToList());
        }
示例#3
0
        public List <string> Resolve(OcelotReRoute source, OcelotReRouteDto destination, List <string> destMember, ResolutionContext context)
        {
            if (source == null || source.UpstreamHttpMethods == null)
            {
                return(null);
            }

            return(source.UpstreamHttpMethods.Select(c => c.Method).ToList());
        }
示例#4
0
        public List <ReRouteDelegatingHandler> Resolve(OcelotReRouteDto source, OcelotReRoute destination, List <ReRouteDelegatingHandler> destMember, ResolutionContext context)
        {
            if (source == null || source.DelegatingHandlers == null)
            {
                return(null);
            }
            foreach (var item in source.DelegatingHandlers)
            {
                destination.AddDelegatingHandler(item);
            }

            return(destination.DelegatingHandlers);
        }
示例#5
0
        public List <ReRouteDownstreamHostAndPort> Resolve(OcelotReRouteDto source, OcelotReRoute destination, List <ReRouteDownstreamHostAndPort> destMember, ResolutionContext context)
        {
            if (source == null || source.DownstreamHostAndPorts == null)
            {
                return(null);
            }

            foreach (var item in source.DownstreamHostAndPorts)
            {
                destination.AddDownstreamHostAndPort(item.Host, item.Port.Value);
            }

            return(destination.DownstreamHostAndPorts);
        }
示例#6
0
        public List <ReRouteUpstreamHttpMethod> Resolve(OcelotReRouteDto source, OcelotReRoute destination, List <ReRouteUpstreamHttpMethod> destMember, ResolutionContext context)
        {
            if (source == null || source.UpstreamHttpMethods == null)
            {
                return(null);
            }

            foreach (var item in source.UpstreamHttpMethods)
            {
                destination.AddUpstreamHttpMethod(item);
            }

            return(destination.UpstreamHttpMethods);
        }
示例#7
0
        public List <ReRouteDownstreamHostAndPortDto> Resolve(OcelotReRoute source, OcelotReRouteDto destination, List <ReRouteDownstreamHostAndPortDto> destMember, ResolutionContext context)
        {
            if (source == null || source.DownstreamHostAndPorts == null)
            {
                return(null);
            }

            List <ReRouteDownstreamHostAndPortDto> dto = new List <ReRouteDownstreamHostAndPortDto>();

            foreach (var item in source.DownstreamHostAndPorts)
            {
                dto.Add(new ReRouteDownstreamHostAndPortDto {
                    Host = item.Host, Port = item.Port
                });
            }

            return(dto);
        }