예제 #1
0
 public LayIMMiddleware(RequestDelegate next, LayIMOptions options, IServiceProvider serviceProvider)
 {
     this.next            = next;
     this.options         = options;
     this.serviceProvider = serviceProvider;
     LayIMServiceLocator.SetServiceProvider(this.serviceProvider);
 }
예제 #2
0
        /// <summary>
        /// 转换路由路径
        /// </summary>
        /// <param name="context"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static string GetRoutePath(this HttpContext context, LayIMOptions options)
        {
            string path   = string.Empty;
            string prefix = options.ApiPrefix;

            if (!string.IsNullOrEmpty(prefix))
            {
                path = context.Request.Path.Value.Substring(prefix.Length);
            }
            else
            {
                path = context.Request.Path.Value;
            }
            return(path);
        }
예제 #3
0
        /// <summary>
        /// 是否LayIM静态资源请求
        /// </summary>
        /// <param name="context"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static bool IsLayIMResourceRequest(this HttpContext context, LayIMOptions options)
        {
            string path = context.GetRoutePath(options);

            return(Regex.IsMatch(path, "^(js/|page/|css/|font/)*.*$"));
        }
예제 #4
0
 /// <summary>
 /// 是否LayIM接口请求
 /// </summary>
 /// <param name="context"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static bool IsLayIMRequest(this HttpContext context, LayIMOptions options)
 {
     return(IsConfigPath(context.Request.Path.Value) || context.Request.Path.Value.StartsWith(options.ApiPrefix, StringComparison.CurrentCultureIgnoreCase));
 }
예제 #5
0
 public static void SetOptions(LayIMOptions options)
 {
     layimOptions = options;
 }
예제 #6
0
 public LayIMMiddleware(RequestDelegate next, LayIMOptions options)
 {
     this.next    = next;
     this.options = options;
 }
예제 #7
0
        /// <summary>
        /// 是否LayIM静态资源请求
        /// </summary>
        /// <param name="context"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static bool IsLayIMResourceRequest(this HttpContext context, LayIMOptions options)
        {
            string path = context.ToRoutePath(options);

            return(path.StartsWith("/js") || path.StartsWith("/css"));
        }