Пример #1
0
        /// <summary>
        /// 产生路由值
        /// </summary>
        /// <param name="requestData"></param>
        /// <returns></returns>
        public IReadOnlyDictionary <string, string> Match(RouteRequestData requestData)
        {
            if (Upstreams.Any() == false)
            {
                return(new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase));
            }

            foreach (var item in Upstreams)
            {
                var values = item.GetRouteValues(requestData);
                if (values != null)
                {
                    return(values);
                }
            }

            return(null);
        }
Пример #2
0
        private IReadOnlyDictionary <string, string> TryGetRouteValues(HttpRequestMessage request)
        {
            var routeData = request.GetRouteData();

            if (routeData?.RouteRule == this)
            {
                return(routeData.Values);
            }

            else if (Upstreams.Any())
            {
                return(Match(new RouteRequestData(request)));
            }

            else
            {
                return(new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase));
            }
        }