Closed wollanup closed 7 years ago
Extending App
is the way to do this at the moment. I expect that in 4.0 we'll convert the route determination logic to middleware so that you can put middleware before and after it.
OK, thank you for your fast answer, I'll wait for 4.0
@akrabat, anywhere for this to be logged as a requested feature, so it doesn't get missed?
This is logged in https://github.com/slimphp/Slim/issues/1686 as:
Remove
determineRouteBeforeDispatch
and make routing a middleware that can be placed where you want it to be. If you don't add it yourself, we would add it immediately before dispatch.
Here is the process I would follow :
My last Middleware "authorization" is ACL service based on routes Names, so it requires
'determineRouteBeforeAppMiddleware' => true,
in config.But if I determine routes before a call to my middlewares, it can't work. e.g : URI :
GET /api/resource/list.json/
Route :$app->get('/resource/list')
URI doesn't match my route pattern.The workaround I currently use is to execute code inside
Slim\App::dispatchRouterAndPrepareRoute()
protected method as a last middleware before Authentification, but maybe there could be a cleaner way to do this without duplication of code or Slim\App class extend. Any thoughts about this ?