thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

/custom/{params:string} dont get set in Request #249

Closed delboy1978uk closed 4 years ago

delboy1978uk commented 5 years ago

The paramaters from the path are not available in the request to any of my middleware, and are only available in the callable at the end of the middleware chain as $args.

I was trying to add a content negotiation HAL middleware to my route /some/route/{id:number}, but there was no no way to get the ID defined in my route path out of the request without parsing it all myself again.

The vars get defined upon case FastRoute::FOUND: in the Dispatcher.

Adding the Route params to the Request's Query Params solves the issue and makes for a far more useful middleware stack. Also it means you could probably deprecate the $args argument and just use the Request itself.

I have forked a branch and will send a pull request. :-)

philipobenito commented 4 years ago

PR added to tags for next release, will close this in favour of the PR, thanks.