cb7f3bb0
chimw: the chi-shaped helpers of the custom services
GetHead registers a read route under GET and HEAD both, which cover, bench and tokens had each spelled out — five copies of three lines, under three names. RenderRefusals points chi's NotFound and MethodNotAllowed at the service's own error page, which spec and dolt install neither of, so a mistyped URL there is the one refusal on the instance that answers in plain text. RequestLogger is a chi LogFormatter emitting slog records, in place of chi's colourised stdlib line on stdout — the highest-volume line a service writes and the only one that was neither structured nor on stderr. It is a second middleware package and not a wing of the first because sr-ht-ecore/middleware needs nothing but net/http and that rule is worth keeping; the boundary is whether the helper has to know what a route is. A request line is Info, a 5xx is Error, and 499 stays Info by being below 500, which is what that code was chosen for. Skipping probe noise is the caller's call, through a predicate. The logger goes outside RecoverPanics so the line reports the error page that was rendered rather than the nothing an unwinding stack has written.
Eugene Blikh <bigbes@gmail.com> — 2026-08-08 21:03:04 UTC
Commit cb7f3bb02407e6da196c57928d28e4ae3298a9b3 —
view raw patch
Parent(s):
c627d4ee
| File | Status | + | − |
|---|---|---|---|
chimw/chimw.go
|
A | +186 | |
chimw/chimw_test.go
|
A | +199 | |
chimw/logger.go
|
A | +256 | |
chimw/logger_test.go
|
A | +347 | |
go.mod
|
M | +1 | |
go.sum
|
M | +57 | |
middleware/middleware.go
|
M | +3 | -2 |