This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 195
Support route-specific middleware pipeline via configuration? #190
Comments
@michaelmoussa Funny — I raised the specter of this in a comment on a previous issue: I like the idea of the array notation, though we'll have to likely find a way to differentiate between that and a callable. I'll do some thinking on that in the coming days. |
Thanks @weierophinney. I had a couple of ideas in mind already, so since it seems you're open to it, I'll submit something and see if it'll work for you. |
@michaelmoussa Awesome; thanks! |
Could be |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When defining routes, we can specify the middleware to be executed in the configuration:
I have a use case where I'd like to service a route by chaining a few different middlewares. They are application-specific middlewares that are shareable among resources (think user input validation, entity retrieval, and things of that nature), but I can only specify a single middleware in this configuration. I considered using the
pre_routing
andpost_routing
configuration pipelines, but they execute too early or too late, respectively, and I only need them to execute for this specific route, not for every request.I managed to implement what I wanted by having my
FooMiddleware
actually be a middleware pipe:Since a
MiddlewarePipe
is itself middleware, Expressive will accept it as the target middleware for this route, and execute the middlewares in the proper sequence.However, it'd be much more convenient to be able to create this pipeline in the configuration rather than needing to create a factory to do it programmatically:
This is currently not allowed because the value of
middleware
must be callable.The text was updated successfully, but these errors were encountered: