Notes for later. Captured 2026-06-07 while rewriting the README and surveying real usage
across w1nterbot, nofy-api, ligma-api.
-
GetContext[T]panics on missing/mismatched value.request.godoes an uncheckedr.Context().Value(id).(*T). If the key is unset or holds a different type it panics. Handlers work around it by only reading keys set via aResolveabove them. Consider the comma-ok form and returningnilinstead (the README documentsnilas the contract):go func GetContext[T any](r *Request, contextId string) *T { t, _ := r.Context().Value(contextId).(*T) return t } -
Rigid
{ "data": ... }response envelope.Response.JSONhard-wraps indata. Bothnofy-apiandligma-apibypass it with their own wrappers (ligma wantsresultinstead ofdata). Options: a configurable envelope key, aRaw/JSONRawthat doesn't wrap, or document the override path clearly (partly done in README). -
Uppercase error-aware methods are incomplete. Only
GET/POST/PUT/DELETEexist (mux.go). NoPATCH/HEAD/OPTIONS/CONNECT/TRACEerror-aware variants — those methods fall back to stdlib handlers. Add the rest (or a genericMethod-stylephi.Handlerregistrar) for consistency. -
No graceful shutdown. Every service uses bare
http.ListenAndServe;nofy-apihas a// TODO: Gracefull shutdowncomment. Consider a smallphi.ListenAndServe/Servehelper with signal handling +http.Server.Shutdown(ctx). -
Validateonly checks presence.requiredflags zero-value fields only — no format, length or range checks. Consider richer tags (e.g.min,max,email) or document that semantic validation stays in the handler. -
Few error constructors. Only
ValidatingError,URL/Query/BodyParameterError,Unauthorized,UnknownError. Projects hand-rollNotFound/Forbidden/Conflictvalues repeatedly. Add common ones (NotFound,Forbidden,BadRequest,Conflict). -
Module versioning mismatch. Tags are
v5.x(latestv5.2.5) butgo.modismodule go.philip.id/phiwithout a/v5suffix. Per Go module rules v2+ needs the major-version suffix in the module path. Verify this resolves correctly for consumers.
- Document
GetContext/SetContext(was in the old README TODO). - Document
Response.Error/Response/UnknownError+ error codes. - Replace chi-style examples with phi-style (
*phi.Response/*phi.Request/*phi.Error). - Fix broken links/badges and remove chi leftovers (Pressly/Cloudflare/Travis, non-existent subpackages docgen/render/httprate/etc.).
- Drop the "might not be ready for production" / "no external dependencies" false claims.
- Add a runnable error-handling example under
_examples/(current examples are chi-era). - Document the
jwtauthsubpackage API on its own (only referenced from middleware so far). - Document
cors.Optionsfields (currently shown by example only).
- CHANGELOG for the phi-specific additions (the linked chi CHANGELOG is stale/irrelevant).
- Tests for the phi extensions (
Validate,Resolve,GetContext, error handler) —validate_test.goexists; expand coverage to the response/error/context helpers.