# Обработка на всеки HTTP метод

> Декларирайте маршрути за GET, POST, PUT, PATCH и DELETE и четете метода от $.method.

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

Първата дума на един маршрут е HTTP методът: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Един и същ URL адрес може да има различен handler за всеки метод, а `$.method` казва на споделения handler кой е използван.

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