コード例 #1
0
        internal RouteHandler Find(string httpMethod, char[] buffer, int len, out RouteMatch routeMatch)
        {
            RouteHandler handler;
            var          reqHash = StringCache.CalcHash(httpMethod, buffer, len);
            int          askSign = -1;

            for (int i = 0; i < len; i++)
            {
                if (buffer[i] == '?')
                {
                    askSign = i;
                    break;
                }
            }
            if (askSign == -1 && Cache.TryGetValue(reqHash, out handler))
            {
                if (handler.Pattern.IsStatic)
                {
                    routeMatch = handler.Pattern.ExtractMatch(handler.Url, 0);
                    return(handler);
                }
            }
            var rawUrl = new string(buffer, 0, len);

            return(FindRoute(httpMethod, rawUrl, reqHash, out routeMatch));
        }
コード例 #2
0
ファイル: Routes.cs プロジェクト: zhxjdwh/revenj
        public RouteMatch?Find(string httpMethod, string rawUrl, string absolutePath, out RouteHandler handler)
        {
            var reqHash = StringCache.CalcHash(httpMethod, absolutePath);

            if (Cache.TryGetValue(reqHash, out handler))
            {
                return(handler.Pattern.ExtractMatch(rawUrl, handler.Service.Length));
            }
            return(FindRoute(httpMethod, rawUrl, reqHash, out handler));
        }