-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Ability to set a different 404 handler based on the subroute #59
Comments
I'll gladly accept a PR that provides this. |
This can be accomplished with a very minor change to the beginning of public function mount($baseRoute, $fn)
{
// Bail if this mount does not match the URI
if(strpos($this->getCurrentUri(), $baseRoute) !== 0){
return false;
}
// ... This change may also resolve #55 since it stops arbitrary code from being run within the mount()'d callable when the route does not match. It is not compatible with #75, but that feature does not exist anyway. |
This solution means that calls to |
Obviously not the best solution, but this could work:
|
I advise against redirection as a means to serve 404 responses. It breaks the web. Perhaps under certain conditions, an action by another request might make that URL no longer a 404 (e.g. user created CMS pages). By redirecting, you've taken away the user's ability to reload the page and get the expected response. Instead, they'll have to go back a page. |
Hi,
example :
In this example, in case of error 404 for the api subroute, a JSON response will be returned.
For the website subroute, a simple HTML page will be returned.
Thanks for your time.
The text was updated successfully, but these errors were encountered: