コード例 #1
0
        /// <summary>
        /// 从配置的路由中复制值
        /// </summary>
        /// <param name="configRoute"></param>
        /// <returns></returns>
        public static RouteContext Copy(RouteContext routeContext, FileRouteConfiguration configRoute)
        {
            routeContext.Authentication         = configRoute.Authentication;
            routeContext.DownstreamScheme       = configRoute.DownstreamScheme;
            routeContext.DownstreamPathTemplate = configRoute.DownstreamPathTemplate;
            routeContext.DownstreamHttpMethod   = configRoute.DownstreamHttpMethod;
            routeContext.DownstreamServiceName  = configRoute.DownstreamServiceName;
            routeContext.DownstreamHostInfos    = configRoute.DownstreamHostInfo;
            routeContext.UpstreamHost           = configRoute.UpstreamHost;
            routeContext.UpstreamPathTemplate   = configRoute.UpstreamPathTemplate;
            routeContext.UpstreamHttpMethod     = configRoute.UpstreamHttpMethod;

            return(routeContext);
        }
コード例 #2
0
        /// <summary>
        /// 获取下游请求信息
        /// </summary>
        /// <param name="routeConfiguration"></param>
        /// <param name="upstreamQueryString">上游请求的查询字符串</param>
        /// <returns></returns>
        private DownstreamRoute GetDownstreamRoute(FileRouteConfiguration routeConfiguration, string upstreamQueryString)
        {
            DownstreamRoute downstreamRoute = new DownstreamRoute();

            var downstreamHostInfo = GetDownstreamHostString(routeConfiguration.DownstreamHostInfo);

            downstreamRoute.Host = downstreamHostInfo.IP;

            downstreamRoute.Port = int.Parse(downstreamHostInfo.Port);

            downstreamRoute.Scheme = routeConfiguration.DownstreamScheme;

            downstreamRoute.PathTemplate = UriMapper.GetRestfullUri(routeConfiguration.DownstreamPathTemplate, upstreamQueryString);

            downstreamRoute.QueryString = upstreamQueryString;

            downstreamRoute.Authentication = routeConfiguration.Authentication;

            return(downstreamRoute);
        }