Example #1
0
        /// <summary>
        /// 自动补全请求
        /// </summary>
        /// <param name="type"></param>
        /// <param name="methodOrUri"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        protected static string richRequest(HttpMethodType type, string methodOrUri, YopRequest request)
        {
            Assert.notNull(methodOrUri, "method name or rest uri");
            if (methodOrUri.StartsWith(request.getServerRoot()))//检查是否以指定字符开头
            {
                methodOrUri = methodOrUri.Substring(request.getServerRoot().Length);
            }
            bool isRest = methodOrUri.StartsWith("/rest/"); //检查是否以指定字符开头

            request.setRest(isRest);                        //临时变量,避免多次判断
            string serverUrl = request.getServerRoot();

            if (isRest)
            {
                methodOrUri = mergeTplUri(methodOrUri, request);
                serverUrl  += methodOrUri;
                string version = Regex.Match(methodOrUri, "(?<=/rest/v).*?(?=/)").Value;
                if (StringUtils.isNotBlank(version))
                {
                    request.setVersion(version);
                }
            }
            else
            {
                serverUrl += "/command?" + YopConstants.METHOD + "=" + methodOrUri;
            }
            request.setMethod(methodOrUri);
            return(serverUrl);
        }