code: function(operation, res) {
        var that = this;
        var method = res.req.method;
  
        return operation.then(function(doc) {
          if (method === 'POST') {
            if (that._path && (that._key || that._index)) {
              res.header('Location', '/' + that._path + '/' + doc[that._key || that._index]);
            }
  
            return res.status(201).json(doc);
          }
  
          return res.status(200).json(doc);
        }, function(err) {
          console.error(err.message);
  
          if (method === 'POST' || method === 'PUT') {
            return res.status(409).end();
          }
  
          if (method === 'GET') {
            res.status(404).end();
          }
  
          return res.status(500).end();
        });
      }
docs: Middleware REST handler for CRUD operations
  
  @param {Promise} operation
  @param {ServerResponse} res