Esempio n. 1
0
        /// <summary>
        /// 直接提供webApi本地直接处理请求,不转发到后端rpcServer
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string SendHttp(HttpContext context)
        {
            var           content  = GetRequestValue(context.Request);
            Args <object> a        = JsonConvert.DeserializeObject <Args <object> >(content);
            var           jSetting = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            };

            a.Headers = GetRequestIp(context);
            if (string.IsNullOrEmpty(a.rid))
            {
                // 提前端产生一个rid
                a.rid = Guid.NewGuid().ToString("N");
            }
            string[] motheds = context.Request.Path.ToString().Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (motheds == null || motheds.Length < 2)
            {
                Result <object> rr = new Result <object>();
                rr.msg = "Uri Error rid=" + a.rid;
                rr.c   = 503;
                rr.v   = default(object);
                return(JsonConvert.SerializeObject(rr, jSetting));
            }
            else
            {
                a.m = motheds[motheds.Length - 1];
                jSetting.DateFormatString = "yyyy-MM-dd HH:mm:ss";
                return(ServerProxy.HttpSend(JsonConvert.SerializeObject(a, jSetting), a.Headers));
            }
        }