Browse Source

adding 408.js

pull/169/head
Harish Krishna 9 years ago
parent
commit
78c112d787
  1. 1
      app.js
  2. 9
      middleware/408.js

1
app.js

@ -52,6 +52,7 @@ app.get( '/reverse', sanitisers.reverse.middleware, controllers.search(undefined
/** ----------------------- error middleware ----------------------- **/
app.use( require('./middleware/404') );
app.use( require('./middleware/408') );
app.use( require('./middleware/500') );
module.exports = app;

9
middleware/408.js

@ -0,0 +1,9 @@
// handle time out errors
function middleware(err, req, res, next) {
res.header('Cache-Control','no-cache');
if( res.statusCode === 408 ){ res.status(408); }
res.json({ error: typeof err === 'string' ? err : 'request time out' });
}
module.exports = middleware;
Loading…
Cancel
Save