# Elke HTTP-methode afhandelen

> Declareer routes voor GET, POST, PUT, PATCH en DELETE en lees de methode uit $.method.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: nl
Content-SHA256: 283872fb9023b179e5fdbfa00e3441e57889d4a76864fcc2ab2461ca4dcbb74f
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Het eerste woord van een route is de HTTP-methode: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Dezelfde URL kan per methode een andere handler hebben, en `$.method` vertelt een gedeelde handler welke is gebruikt.

```js controllers/items.js
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 });
}
```
