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
fixes #1 #2
fixes #1 #2
Conversation
1 similar comment
Is the errHandler because you'd provide a new one for use on the "upgrade" event? I would also hesitate calling this an error handler, as it is simply a "default" or unmatched handler, yes? Maybe we expose this as |
It should be invalid to not have a default handler, so the check for |
the So in a sense, it's a error (no route matched). The original behavior here is 404 and |
I agree the |
Not on my phone anymore so perhaps I can write a more detailed answer. Don't think This would be better exposed as a default handler. As that's the only "error" it handles. For example: PathRouter.prototype.default = function setDefaultHandler () {
this._router.default.apply(this._router, arguments);
return this;
} function defaultHandler (req, res) { /* ... */ }
function Router () {
// ...
this._default = defaultHandler;
}
Router.prototype.default = function setDefaultHandler (fn) {
if ('function' !== typeof fn) {
throw new Error('"fn" must be a function');
}
this._default = fn;
}
Router.prototype.dispatch = function dispatch (req) {
// ...
this._default.apply(this, arguments);
} If it doesn't matter to you - I could actually write that out and commit it with tests in place. |
I've got those changes in #3 which I'll merge once the tests pass. I'll do the any-arity handler change after |
I see your point now. Yes I agree in this perspective it can be called I don't really mind the name, so long as the any-arity handler is there :) Thanks for the help! |
No description provided.