visionmedia / express-resource

Resourceful routing for Express
1.41k stars 140 forks source link

custom mapping with strings (includes middleware commits) #46

Closed hunterloftis closed 10 years ago

hunterloftis commented 12 years ago

A 1-line addition (+tests) for:

  server.resource('sessions', controllers.session)
    .map('all', '/login', 'new')
    .map('all', '/logout', 'destroy');

Is this a bug? While testing this I noticed that if any resource has a 'show' method custom routes won't work on it, since 'show' will be defined before the custom routes and so the custom mapping will be interpreted as an ID. The fix sounds simple - mount custom routes ahead of default routes - but since I don't really know the inner workings of express I don't want to jump into that right now.