Skip to content

Instantly share code, notes, and snippets.

@bbraithwaite
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbraithwaite/9fad696fe5380baeb27c to your computer and use it in GitHub Desktop.
Save bbraithwaite/9fad696fe5380baeb27c to your computer and use it in GitHub Desktop.
'use strict';
module.exports = function(app) {
var categories = require('../../app/controllers/categories.server.controller');
app.route('/categories')
.get(categories.list)
.post(categories.create);
app.route('/categories/:categoryId')
.get(categories.read)
.put(categories.update)
.delete(categories.delete);
// Finish by binding the article middleware
// What's this? Where the categoryId is present in the URL
// the logic to 'get by id' is handled by this single function
// and added to the request object i.e. request.category.
app.param('categoryId', categories.categoryByID);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment