visionmedia / express-resource

Resourceful routing for Express
1.41k stars 140 forks source link

Handle not found routes #51

Closed panosru closed 12 years ago

panosru commented 12 years ago

I used to set app.all('/*', function (req, res, next) ... as my last route in order to handle routes that are not found, it used to work fine but now that I use express-resource it seems that static content like .css, .js, .jpg are processed by the router without express-resource they are not processed and app.all('/*'... handles not found routes properly

panosru commented 12 years ago

I see this is related to #38

tj commented 12 years ago

ideally they are whitelisted since there's an infinite possibility of extensions really. However it's easy to a) add express.static() above app.router, or add app.use(function(req, res, next){ my 404 stuff here }) below app.router and all the other middleware

panosru commented 12 years ago

@visionmedia this is what I have now and is not working for me... if you check my application index you will see that I call App.static() before the router and the handler after the router...

tj commented 12 years ago

add a function after ErrorHandler.handle, if connect is responding with "Cannot GET /whatever" etc you can respond in that function

panosru commented 12 years ago

@visionmedia ok I used it in another way, some-how like you proposed with a fn after ErrorHandler.handle method. :)