-
Notifications
You must be signed in to change notification settings - Fork 3
Over riding Status Handlers
cainus edited this page Apr 14, 2012
·
6 revisions
Detour handles some http status code responses itself, by simply returning the status code with an empty body. You can over-ride this behaviour in instances of it simply by monkey-patching:
var detour = require('detour').detour;
var router = new detour('/api', {});
router.handle404 = function(req, res){
res.send(404, "this is a custom 404 error")
}Codes that are supported (and can be overridden) are:
- 414 (URI too long): method name: handle414()
- 404 (URI not found): method name: handle404()
- 405 (method not supported for resource): method name: handle405()
- 501 (method not implemented by server): method name: handle501()