/// <summary> /// 注册接口中间件 /// </summary> /// <param name="app"></param> /// <param name="option"></param> /// <returns></returns> public static IApplicationBuilder UseGateaway(this IApplicationBuilder app, Action <GateawayOption> option = null) { GateawayOption config = app.ApplicationServices.GetService <GateawayOption>();; option?.Invoke(config); app.UseMiddleware <GateawayLogMiddelware>(); app.UseMiddleware <GateawayMiddleware>(); return(app); }
/// <summary> /// 是否是回调函数 /// </summary> /// <param name="httpContext"></param> /// <returns></returns> public static bool IsCallback(this HttpContext httpContext) { GateawayOption config = httpContext.RequestService <GateawayOption>();; if (httpContext.Forms().ContainsKey("method")) { if (httpContext.Forms()["method"].Split('.').Any(t => config.NotVerifyForMethods.Contains(t))) { return(true); } } return(httpContext.Request.Path.ToString().ToLower().Split('/').Any(t => config.NotVerifyForMethods.Contains(t))); }