Closed atrauzzi closed 8 years ago
Does the way it's implemented mean that you're rebuilding an entire new application pipeline for every request? Is there any risk of this being inefficient?
Actually, the branched pipeline is only built at startup time, thanks to the special Use
overload that takes a Func<RequestDelegate, RequestDelegate>
. The only part which is executed per-request is the request delegate itself:
return context => {
if (condition(context)) {
return branch(context);
}
return next(context);
};
I love it. Thanks! :)
@PinpointTownes I was just going through the docs.asp.net and noticed the Map
method. Any differences between that and what you've made?
Ahh, I see. So if I used MapWhen
vs UseWhen
, I'd have to create two completely separate pipelines? So UseWhen
is good if you want to DRY out the setup of pipelines?
Yep.
I've actually enjoyed similar functionality to the
UseWhen
extension method in other frameworks and languages, but I'm wondering...Does the way it's implemented mean that you're rebuilding an entire new application pipeline for every request? Is there any risk of this being inefficient?