4 ms·
This isn't so much a critique of the HTTP handlers themselves but relying on (and stuffing a ton of shit into) context as a way of dealing with complex request/
by halfmatthalfcat 4y ago
This isn't so much a critique of the HTTP handlers themselves but relying on (and stuffing a ton of shit into) context as a way of dealing with complex request/response patterns was a major headache.
Trying to implement a circuit breaker against multiple upstreams for a single request in Go was a nightmare.
- morelisp 4y agoPeople put way too much stuff in the context (whether that's the req.Context() or the gin.Context or whatever). It should only be for things that are request-scoped and need to cross middlewares that aren't aware of them. Most such middlewares (logging, metrics, last-ditch error handling) get put at the front of the chain anyway. A circuit-breaker is basically by definition not request-scoped, so should not go in the context.