fabpot/Silex — pull request #270 by DrBenton (2012-02-29 21:33:24+00:00)
Title: Routes Middlewares feature addition to Silex

Hi !

As discussed in #262, here is an implementation of the Routes Middlewares feature, shipped with its Unit Test (all Silex Unit Tests still run successfully, of course).

Silex still acts the same (the feature addition is 100% backward compatible), excepted that you can use additional parameters with the Application ```match```, ```get```, ```post``` ```put``` and ```delete``` methods, between the ````$pattern``` and ```$to``` params.
Any additional parameter used this way is considered as a Route Middleware, i.e. a PHP callable. When the Route is matched, the associated middlewares are triggered just before the route callback.

As you can see, it's a very simple implementation, but I think it can be a very handy feature for a lot of use cases.

Olivier