Skip to content

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")
}

Methods that are supported (and can be overridden) are:

  • handle414() (URI too long)
  • handle404() (URI not found)
  • handle405() (method not supported for resource)
  • handle501() (method not implemented by server)

Clone this wiki locally