# Gérer chaque méthode HTTP

> Déclarez des routes pour GET, POST, PUT, PATCH et DELETE et lisez la méthode depuis $.method.

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

Le premier mot d'une route est la méthode HTTP : `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. La même URL peut avoir un gestionnaire différent pour chaque méthode, et `$.method` indique à un gestionnaire partagé laquelle a été utilisée.

```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 });
}
```
