# Obsługa każdej metody HTTP

> Deklaruj trasy dla GET, POST, PUT, PATCH i DELETE i czytaj metodę z $.method.

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

Pierwsze słowo trasy to metoda HTTP: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Ten sam URL może mieć inny handler dla każdej metody, a `$.method` mówi współdzielonemu handlerowi, która została użyta.

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