public static IOcelotPipelineBuilder MapWhen(this IOcelotPipelineBuilder app, Predicate predicate, Action <IOcelotPipelineBuilder> configuration) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (predicate == null) { throw new ArgumentNullException(nameof(predicate)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var branchBuilder = app.New(); configuration(branchBuilder); var branch = branchBuilder.Build(); var options = new MapWhenOptions { Predicate = predicate, Branch = branch, }; return(app.Use(next => new MapWhenMiddleware(next, options).Invoke)); }
public MapWhenMiddleware(OcelotRequestDelegate next, MapWhenOptions options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _next = next; _options = options; }
public static IOcelotPipelineBuilder MapWhen(this IOcelotPipelineBuilder app, Func <IOcelotPipelineBuilder, Predicate> pipelineBuilderFunc) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (pipelineBuilderFunc == null) { throw new ArgumentNullException(nameof(pipelineBuilderFunc)); } var branchBuilder = app.New(); var predicate = pipelineBuilderFunc.Invoke(app); var branch = branchBuilder.Build(); var options = new MapWhenOptions { Predicate = predicate, Branch = branch }; return(app.Use(next => new MapWhenMiddleware(next, options).Invoke)); }