How to register After Router Middleware / Run Callback before calling $router->run()
- Dominant language
- PHP
- Stars
- 1.1k
- Forks
- 236
- PR merge metrics
- No merged PRs in 30d
Description
Hi
**First:**
Is it possible to add After Router Middleware earlier before actually calling $router->run()
If not please provide a method for doing so. I will suggest something like this or similar
`$router->addAfterCallback($callback = null)`
// do other stuff with router ...
//finally
`$router->run()`
**Secondly:**
The After Router callback could accept an array of callables to run since we might want to run a list of callbacks or middlewares not just one.
We could then modify the above method as such:
`$router->setAfterCallback(array $callback = array())`
We can then execute in the run method as such:
see line 296
`} // If a route was handled, perform the finish callback (if any)
else {
if ($callback && is_callable($callback)) {
$callback();
}
}`
becomes:
`} // If a route was handled, perform the finish callback (if any)
else {
foreach ($this->callbacks as $callback) {
if ($callback && is_callable($callback)) {
$callback();
}
}
}
`
thanks
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.