Add a helper to use pipelines with (New)Handlers #293
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(The code is still missing tests & documentation, but I would like to get some initial feedback before I add those).
This was the solution I ended up with for #292. While cleaning the code up, I remembered that when I was first looking into solutions for my issue, I was very surprised that there didn't seem to be a standard way to use pipelines with plain handlers, only
Routers
appeared to be supported. So I decided to phrase my solution in those terms: A helper to use a pipeline with a plain handler. (I'd be happy to accept suggestions regarding naming, code organization and better bounds).(Also note that I find the behavior of the
Router
, to only apply pipelines when it successfully matches a route, unexpected and surprising. But even if that were to change, I think the utility proposed here would still be valuable since it allows using pipelines without the router).cc @whitfin, @colinbankier
Fixes #292