Per http://www.slimframework.com/docs/concepts/middleware.html, one can add middleware to an application, route, or group.
How should one add middleware to all routes (i.e. to the application), but exclude it from specific routes?
EDIT. As a possible solution, I am thinking of adding some logic in my application middleware to bypass the middleware functionality. Getting the method is easy enough using $request->getMethod()
, however, the other URL methods described by http://www.slimframework.com/docs/objects/request.html are not available in the middleware.
You can access the uri inside middleware with the following.
$uri = $request->getUri()->getPath();
With that information you can return from the middleware early if the $uri
matches path you want to exclude from the middleware.