Day 091 — Week 1 Review + Recall¶
Month 4 · Week 1 · ⬅ Day 090 · Day 092 ➡ · Journal index
🎯 Learning Objective¶
Consolidate Week 1 (net/http, routing, middleware, JSON, server lifecycle) with closed-book recall, then capture lessons in the weekly review.
📚 Topics¶
- Spaced recall across Days 085–090
- Gaps to carry into Week 2 (databases)
📖 Reading / Sources¶
- Re-read my own Days 085–090 notes (closed-book first)
-
net/httpoverview — skim to confirm recall
📝 Notes¶
- The whole stack rests on one interface,
http.Handler, withHandlerFuncas the function adapter → [[http-handler]]. - Go 1.22's
ServeMuxdoes method + wildcard routing and auto 404/405; chi adds nested routers and groups when the tree grows → [[router-choice]]. - Middleware =
func(http.Handler) http.Handler;Chaincomposes outermost-first; Recoverer goes near the top → [[panic-recover]]. - JSON helpers: header before
WriteHeader,DisallowUnknownFields,MaxBytesReader, map decode errors to status codes → [[error-wrapping]]. - Lifecycle: server timeouts +
Shutdown(ctx);ErrServerClosedis success → [[http-timeouts]] / [[context]].
🏋️ Exercises / Practice¶
| Exercise | Status | Link |
|---|---|---|
All Week 1 exercises green (go test ./...) |
✅ | exercises/month-04/week-1 |
Full write-up, re-quiz, and metrics:
week-1-review.md
🐛 Mistakes Made¶
- On recall I blanked on the exact
Chainloop direction — re-derived it from the "outermost-first" rule rather than memorising the index math.
❓ Open Questions¶
- How much of this stays the same once a real database and
database/sqlenter the picture next week? (The handler/JSON/middleware layers shouldn't change.)
🧠 Active Recall (answer without looking)¶
- Q: Which status does the stdlib mux send for a known path hit with an unregistered method?
A
`405 Method Not Allowed`, with an `Allow` header listing the registered methods.- Q: How should a handler treat
http.ErrServerClosedfromListenAndServe?
A
As the expected success signal after `Shutdown` — match it with `errors.Is` and ignore it.🪶 Feynman Reflection¶
A Go web service is layers around one interface: route to a handler, wrap it in middleware, decode/encode JSON at the edges, and manage the server's life with timeouts and graceful shutdown. Almost none of it needs a framework.
🕳️ Knowledge Gaps¶
- Forwarding optional
ResponseWriterinterfaces (Flusher/Hijacker) through wrappers — carry into a later streaming day.
✅ Summary¶
Week 1 is solid: I can build, route, wrap, and gracefully run a stdlib HTTP service, and I've logged the fuzzy spots for spaced repetition.
⏭️ Next Steps / Prep for Tomorrow¶
- Day 092:
database/sql— connections, queries, and the standard DB API.
| Time spent | Difficulty | Confidence |
|---|---|---|
| 75 min | 🟦⬜⬜⬜⬜ | 🟦🟦🟦🟦⬜ |
Suggested commit: docs(journal): month 4 week 1 review + recall (day 091)