Skip to content

Instantly share code, notes, and snippets.

@jameswritescode
Last active September 27, 2015 04:38
Show Gist options
  • Select an option

  • Save jameswritescode/5b55b50a153ebd640d44 to your computer and use it in GitHub Desktop.

Select an option

Save jameswritescode/5b55b50a153ebd640d44 to your computer and use it in GitHub Desktop.
/**
* If a prefix is provided, the value will be prepended to the routes defined.
*
* It is optional to override the controller name if prefix is being used, so
* with the example given it would create routes like this:
*
* /users/:user_id/pets
* /users/:user_id/pets/:pet_id
**/
exports.prefix = '/users/:user_id';
/**
* name is an optional argument that you'll usually only modify if you've
* added a prefix to the controller. name is generally assumed based off the
* file name, but if you've named the file something like user-pets then you'd
* get whacky routes like /users/:user_id/user-pets and that would be weird.
**/
exports.name = 'pets';
/**
* Dictates what kind of route set we're defining. Two valid values are:
*
* resource, resources
*
* If it is a resources it will check for collection and member routes.
**/
exports.type = 'resources';
// Code to execute before a request.
exports.before = function(req, res, next) {
};
exports.routes = {
'index': function(req, res, next) { // GET
},
'show': function(req, res, next) { // GET
},
'new': function(req, res, next) { // GET
},
'create': function(req, res, next) { // POST
},
'edit': function(req, res, next) { // GET
},
'update': function(req, res, next) { // PUT
},
'destroy': function(req, res, next) { // DELETE
},
members: { // GET
// /users/:user_id/pets/:pet_id/name
'name': function(req, res, next) {
}
},
'collection': { // GET
// /users/:user_id/pets/search
'search': function(req, res, next) {
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment