Building APIs
summary
Explains how to build production-ready web APIs using the standard library around http.HandlerFunc and the ResponseWriter/Request pair, favors JSON-only endpoints, and shows concrete tooling: routing with Gorilla M (path params and method-specific handlers), per-request DB session handling with mgo stored in request context, a reusable respond/decode/OK-validation pattern, composable middleware via adapter functions, and testing with the Testify style plus net/http/httptest server and table-driven tests.
AI-written summary · about
chapters (26)
- 0:00Introduction
- 1:20What are APIs
- 1:34Why use Golang
- 2:23Building APIs in Go
- 4:30ResponseWriter
- 4:55Request
- 5:30Routing
- 6:55HTTP Router
- 8:33Respond with Data
- 10:20MapString Interface
- 12:00Public Methods
- 13:00OK Pattern
- 17:18Middleware
- 18:35Server Types
- 19:58Sharing Data
- 21:20MongoDB Wrapper
- 26:57Using Adapters
- 32:17Using Flags
- 35:44HTTP Test
- 38:14Table Testing
- 40:26Teardown
- 41:17Golang Community
- 42:24Questions
- 44:37Middleware vs Adapter
- 47:25Panic
- 49:04Interfaces








