Closed acelaya closed 8 years ago
It's for re-usability, read that last sentence:
Each middleware can itself be middleware, and can attach to specific paths, allowing you to mix and match applications under a common domain. As an example, you could put API middleware next to middleware that serves its documentation, next to middleware that serves files, and segregate each by URI:
$app->pipe('/api', $apiMiddleware);
The handlers in each middleware attached this way will see a URI with that path segment stripped, allowing them to be developed separately and re-used under any path you wish.
https://docs.zendframework.com/zend-stratigility/middleware/
Ok, that makes sense :) I'm closing the issue then
In an Expressive app, I've been trying to do some logic based on the route path in a middleware where the path is set to a specific value ('/rest').
I've seen that
Zend\Stratigility\Next
strips the specified part from the beginning of the path for that middleware only, so if the dispatched route is '/rest/v1/foo/bar', doing$request->getUri()->getPath()
inside that middleware results in /v1/foo/bar, while doing it on any other middleware where the path has not been set, results in /rest/v1/foo/barIs that the intended behavior? I find it a little bit counterintuitive.