/// <summary> /// 自定义分支路由 /// </summary> /// <param name="app"></param> /// <param name="path">分支路由</param> /// <param name="setup">配置项</param> public static void UseCodeIntelligencing(this IApplicationBuilder app, [NotNull] PathString path, [NotNull] Action <CodeIntelligencingOptions> setup) { CodeIntelligencingOptions options = new CodeIntelligencingOptions(); setup(options); Func <HttpContext, bool> predicate = context => { return(context.Request.Path.StartsWithSegments(path, out var remaining)); }; app.MapWhen(predicate, b => b.UseMiddleware <CodeIntelligencingMiddleware>(Options.Create(options))); }
public CodeIntelligencingMiddleware(RequestDelegate next, IOptions <CodeIntelligencingOptions> options) { _next = next; _options = options.Value; }