# Leggere i parametri dell'URL in una route

> Dichiara segmenti dinamici come {id} in una route e leggili da $.params.

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

Racchiudi un segmento dell'URL tra parentesi graffe e Total.js ne espone il valore in `$.params`. Una route può contenere tutti i parametri che servono.

```js controllers/users.js
exports.install = function() {
	ROUTE('GET /users/{id}/', show_user);
	ROUTE('GET /users/{id}/posts/{post}/', show_post);
};

function show_user($) {
	$.json({ id: $.params.id });
}

function show_post($) {
	$.json({ id: $.params.id, post: $.params.post });
}
```

`$.json()` invia il valore come JSON. I parametri sono sempre stringhe; validali o convertili tu, oppure dichiara i loro tipi in un'azione (vedi la ricetta sulle azioni).
