示例#1
0
        public HttpAction GetAction(string method, string path)
        {
            if (path.StartsWith('/') == false)
            {
                path = '/' + path;
            }

            string routePath = method + path;

            routePath = routePath.Split('?')[0].ToLower();
            if (_rootNode.TryGet(routePath.Split('/'), 0, out var result) == false)
            {
                return(null);
            }

            return(result.Value);
        }
示例#2
0
        public bool TryGet(string[] block, int depth, out RouterNode <T> result)
        {
            var word = block[depth];

            if (this.childrun.TryGetValue(word.ToLower(), out result) == false)
            {
                if (this.childrun.TryGetValue(_parameterWord, out result) == false)
                {
                    return(false);
                }
            }

            depth++;

            if (depth < block.Length)
            {
                return(result.TryGet(block, depth, out result));
            }
            else
            {
                return(true);
            }
        }