# Jede HTTP-Methode behandeln

> Deklariere Routen für GET, POST, PUT, PATCH und DELETE und lies die Methode aus $.method.

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

Das erste Wort einer Route ist die HTTP-Methode: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Dieselbe URL kann für jede Methode einen anderen Handler haben, und `$.method` sagt einem gemeinsamen Handler, welche verwendet wurde.

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