chi is a lightweight Go HTTP router for defining parameterized routes and connecting HTTP requests to handlers. It fills a gap in Go’s standard http package, whose routing support is not robust or convenient for paths such as /tasks/{taskID}. section 5.1 section 1.7
A useful mental model is a layered API: the Go HTTP server listens for requests, chi supplies routes, routing, and handlers, and application code performs the worker’s operations. section 5.1
A worker API can map HTTP methods and paths to task operations:
- GET /tasks returns a list of tasks. section 5.1
- POST /tasks creates or starts a task. section 5.1
- DELETE /tasks/{taskID} stops the task identified by the path parameter. section 5.1
Figure 5.2 Internally, the worker’s API is composed of an HTTP server from the Go standard library; the routes, router, and handlers from the chi package; and, finally, our own worker.
The architecture figure makes the boundary between Go’s HTTP server, chi’s routing layer, and application handlers explicit. section 5.1
