Project: Bookstore API Capstone
Project: Bookstore API Capstone
Overview
Combine this part into one Bookstore API binary: modular layout, REST, middleware, auth, DB interface, tests, graceful shutdown.
Scope
| Route | Access |
|---|---|
GET /healthz |
public |
GET /readyz |
public |
GET /api/books |
public |
GET /api/books/{id} |
public |
POST /api/books |
admin |
POST /api/auth/login |
public |
POST /api/auth/logout |
auth |
GET /api/me |
auth |
Checklist
internal/layout (272)
- memory store + interface (275)
- middleware chain: recover, request ID, log, max body (280)
- bcrypt login + session cookie (277)
- role check on create (277)
- graceful Shutdown (281)
- table tests + httptest (279)
- optional rate limit on login (282)
Milestone order
1. health + list books (memory)
2. create book (no auth)
3. login + session + protect create
4. middleware + shutdown
5. tests
6. JSON error envelope consistency
Stretch
- HTML list page (274)
- Postgres driver switch (275)
-strictsecurity headers via reverse proxy notes
- OpenAPI via Huma later (part 08-web)
Done when
go test ./...
go run ./cmd/bookstore
curl -s localhost:8080/api/books | jq .Login, set cookie jar, create book as admin; anonymous create returns 401.