-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Should there be a way to set a default route? (not found) #13
Comments
meeh.. maybe good point. i'll look at that in one two days. it is more correct to be said 404 route, not router. but yea i understand. thanks |
I can propose PR with maybe new method The most simple and straightforward way, i suppose :) |
I'm not sure. Or at least I don't see sense to add Don't know, let me think it. :) |
Koa by default send 404 if nothing happen. As about should it call the next middleware if route not found... i'm still not sure. I believe I made it the same way as |
The idea is to let your user to decide what to do if it cannot hit any route. E.g. https://github.com/DoumanAsh/lazy-http-can/blob/master/server/index.js#L22-L29 It would be good to let user customize 404 response without need to add own middleware.
It should and it is doing so right now, no need to change it :) |
Mmm. Maybe we can add or just: return typeof this.options.notFound === 'function'
? this.options.notFound(ctx, next)
: next() |
I'll try but isn't UPD: Code
|
Yea, they are passed to
worse idea would be to allow passing options to
self preference is camelCase, so PR is is welcome for that line. But please use the commit convention. |
@DoumanAsh just published 2.1 :) |
Thanks, wanted to do it myself, but i got a bit busy :) |
While looking into code i found that regardless if route is found or not, next middleware is called. So you cannot exactly be sure without examining koa context wether route is matched or not.
What do you think about adding possibility of configuring default router(i.e. 404 router)?
The text was updated successfully, but these errors were encountered: