jfhbrook / node-ecstatic

A static file server middleware that works with core http, express or on the CLI!
https://github.com/jfhbrook/node-ecstatic
MIT License
975 stars 194 forks source link

Let handleError be a function #152

Closed domenic closed 9 years ago

domenic commented 9 years ago

It'd be cool if I could intercept 404s and then serve up my own response.

jfhbrook commented 9 years ago

Set handleError to false and deal with the 404 in the callback. Something like:

ecstatic({ root: __dirname + '/public', handleError: false })(req, res, function(err) {
  if (res.statusCode === 404) {
    // Do something about it