liveBook · Manning

Path variable

A path variable is a named value embedded in a request URL path and made available to the handler processing that request.

How 2 Manning books explain it

Go in Practice, Second Edition

A path variable is a named value captured from a matched URL path and made available to the request handler.

How it is used
Routes requests containing URL-path identifiers to handlers that need those values.
How deep it goes
Works through route registration, value extraction, integer conversion, and response checks; does not develop advanced router internals.
Examples
Demonstrates `GET /comments/{id}` for comment lookup and `GET /goodbye/{name}` for a named greeting response.
What you can do after
Apply it via Go’s ServeMux and Request.PathValue to read a named path segment in an HTTP handler.

Read how Go in Practice, Second Edition explains path variable →

Spring in Action, Sixth Edition

A path variable is a value embedded in a URL path and bound to a controller method parameter.

How it is used
Retrieves one REST resource by binding a URL path value to a controller method parameter.
How deep it goes
Explains placeholders, parameter binding, repository lookup, Optional results, and explicit 404 handling.
Examples
Uses a taco endpoint that maps /api/tacos/{id} to a repository lookup by Long ID.
What you can do after
Apply it via Spring REST annotations to retrieve an identified resource and return an appropriate success or not-found response.

Read how Spring in Action, Sixth Edition explains path variable →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.