-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
404 page #6
Comments
Thanks, good question! By default, the router executes all routes that match. You could say it combines the defined routes with But as each route definition returns whether the route matches, you can change it so that the router executes only the first matching route. Instead of the default $router->get('/', function () {
// do something
}); just write $router->get('/', function () {
// do something
}) && exit; to combine them with If you do that, you can simply include your 404 page after all route definitions. It will only be shown if no route matched. This is available as of today. Alternatively, we could include a new method like Does that help? |
Has the
|
That feature is indeed not available yet. Sorry for that! In the meantime, the solution we proposed above $router->get('/', function () {
// do something
}) && exit;
$router->post('/sign-up', function () {
// do something
}) && exit;
\http_response_code(404); or your solution $matched = false;
$router->get('/', function () {
// do something
}) && ($matched = true);
$router->post('/sign-up', function () {
// do something
}) && ($matched = true);
if (!$matched) {
\http_response_code(404);
} should both work fine, although admittedly being a little more verbose. |
Hi nice done! But what if I want to add a 404 page? It would really help me if you have an option for this!
The text was updated successfully, but these errors were encountered: