Margot's last request: once a courier has dropped off a parcel, they tap “Delivered” in the app, and the app files it with the finished deliveries.
Your mission
- Complete the controller's
Livrermethod (“deliver”): it marks the delivery from the URL as delivered (livreeset to true) in the table. - It responds 204, with no content.
- An unknown number responds 404 with
{"erreur": "delivery not found"}. - Wire it to
PATCH /api/deliveries/{id}/delivered, in the API group.
Reminder
Update(columns) changes the rows selected by the query, like DB::table()->where()->update() in Laravel. It returns a *db.Result whose RowsAffected tells how many rows changed: that's how you know, without reading the table again, whether the delivery existed.
PATCH changes part of a resource, where PUT replaces it entirely. A 204 No Content response says “done” without sending anything back: the app will read the delivery again if it needs to.
The round is complete: routes, controllers, a view, validation, middleware and a database. You've covered what a web framework does day to day, in Go.