Part 3: The last upgrade
Pagination, update endpoint, request scoped logging, and lightweight OpenAPI
By now we have a small Go API that is not embarrassing.
We have routes, a service layer, middleware, timeouts, and tests. That is already better than most code that ships.
For the last part, we are going to add the stuff that turns “cute demo” into “this could actually run”:
- Pagination for
GET /links PUT /links/{id}to update the note- Structured enough logging so you can trace a request without reading tea leaves
- A small OpenAPI spec so other people do not have to guess your API
Still simple. Still standard library.
Step 1: Add pagination to the store and service
We will do offset pagination because it is easy to understand. Cursor pagination is better at scale, but you can add it later when you actually have scale. Most people add it early as a personality trait.
Update `internal/links/store.go`
Replace the Store interface and add a paginated list method. Also update the memory store.