# Tratarea fiecărei metode HTTP

> Declară rute pentru GET, POST, PUT, PATCH și DELETE și citește metoda din $.method.

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

Primul cuvânt al unei rute este metoda HTTP: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Același URL poate avea un handler diferit pentru fiecare metodă, iar `$.method` îi spune unui handler comun care a fost folosită.

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