A controller must have one or more functions to handle requests, one for each different http method: GET, POST, DELETE, etc. For every request sent to the controller the appropriate function will be called.

The functions that handle the requests can be exposed with the exports keyword.

// Handles a GET request
exports.get = function(req) {}

// Handles a POST request = function(req) {}

A handler function receives a parameter with a request object, and returns a response object.

exports.get = function(request) {

  if (request.mode === 'edit') {
    // do something...

  var name =;'Name = %s', name);

  return {
    body: 'Hello ' + name,
    contentType: 'text/plain'