Build a production-shaped HTTP API in Go using only the standard library plus a light router. You will serve routes with net/http and ServeMux, encode and decode JSON, add middleware and request context, implement a full REST CRUD resource, and shut the server down gracefully.
Watch the free preview
The net/http server and ServeMux — free to watch, no account needed.
What you'll learn
- Build an HTTP API in Go using net/http, handlers and ServeMux
- Encode and decode JSON safely for request and response bodies
- Add cross-cutting middleware and pass values through request context
- Implement a full REST CRUD resource with method-based routing
- Introduce the chi router and shut a server down gracefully
Syllabus
Serving HTTP with net/http
The net/http server and ServeMuxFree preview
Reading requests and writing responses
JSON and a REST Resource
Encoding and decoding JSON
A REST CRUD resource with method routing
Middleware and Context
Middleware in Go
Request context and cancellation
Production-Ready APIs
Routing with the chi library
Graceful shutdown and server configuration
Lab — 10 Exercises & Solutions
Exercises 1–5
Exercises 6–10