Gestiona cada método HTTP
La primera palabra de una ruta es el método HTTP: GET, POST, PUT, PATCH, DELETE. La misma URL puede tener un manejador distinto para cada método, y $.method le dice a un manejador compartido cuál se usó.
exports.install = function() {
ROUTE('GET /items/', list);
ROUTE('POST /items/', create);
ROUTE('PUT /items/', replace);
ROUTE('PATCH /items/', change);
ROUTE('DELETE /items/', remove);
};
function list($) {
$.json({ action: 'list', method: $.method });
}
function create($) {
$.json({ action: 'create', method: $.method });
}
function replace($) {
$.json({ action: 'replace', method: $.method });
}
function change($) {
$.json({ action: 'change', method: $.method });
}
function remove($) {
$.json({ action: 'remove', method: $.method });
}