COURSE / REAL PRACTICE
Build your first HTTP service
Build a standard-library Go notes API with explicit server configuration, bounded JSON, deliberate routes, repository boundaries and handler tests.
Read the explanation and diagrams, then work through the practice. Your browser profile supplies your saved progress.
What you’ll work toward
Build and test a working JSON notes API, then run the supplied loopback server with explicit timeouts and graceful shutdown. Hosted exercises use request/response recorders without opening sockets.
Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.
Before you start
This course builds on these skills:
- Packages, modules & contract tests
- Capstone: deterministic JSON log summary
- Methods, status codes & retry meaning
- JSON decoding, schemas & explicit errors
Individual lessons can add prerequisites. Your lesson progress shows your actual readiness.
A look inside the first lesson
Configure the server and own its lifetime
package main
import ("fmt";"net/http";"time")
func main(){
h:=http.HandlerFunc(func(w http.ResponseWriter,r *http.Request){w.WriteHeader(202)})
s:=&http.Server{Addr:"127.0.0.1:0",Handler:h,ReadHeaderTimeout:2*time.Second}
fmt.Println(s.Addr,s.ReadHeaderTimeout)
}Your lesson sequence
Follow the same units and lessons in either view. Prerequisite links and your practice progress stay with each lesson.
Server, routes and bounded inputs
- LESSON 01.01
Configure the server and own its lifetime
Use an explicit handler, loopback address and finite server limits; distinguish configuration, serving and graceful shutdown.
Open lesson - LESSON 01.02
Route methods and canonical paths deliberately
Separate missing routes from unsupported methods, preserve an explicit Allow contract and reject ambiguous note identifiers.
Open lesson - LESSON 01.03
Decode bounded JSON before changing state
Read at most a declared body bound, reject duplicate/unknown fields and validate a trimmed title without leaking partial input.
Open lesson
Responses, storage and evidence
- LESSON 02.01
Commit one consistent JSON response
Encode before committing headers, preserve JSON and length metadata, suppress HEAD bodies and propagate write failures.
Open lesson - LESSON 02.02
Put mutable state behind a repository boundary
Use a synchronized bounded in-memory store with monotonic IDs, stable ordering and snapshots that cannot mutate stored notes.
Open lesson - LESSON 02.03
Test the whole exchange, not just the status
Build a read-only handler probe that checks status, headers and exact fixture bodies, and prove it rejects plausible broken handlers.
Open lesson