Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 3.46 KB

TODO.md

File metadata and controls

61 lines (48 loc) · 3.46 KB

phi — open items / TODO

Notes for later. Captured 2026-06-07 while rewriting the README and surveying real usage across w1nterbot, nofy-api, ligma-api.

Library (code)

  • GetContext[T] panics on missing/mismatched value. request.go does an unchecked r.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 a Resolve above them. Consider the comma-ok form and returning nil instead (the README documents nil as 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.JSON hard-wraps in data. Both nofy-api and ligma-api bypass it with their own wrappers (ligma wants result instead of data). Options: a configurable envelope key, a Raw/JSONRaw that doesn't wrap, or document the override path clearly (partly done in README).

  • Uppercase error-aware methods are incomplete. Only GET/POST/PUT/DELETE exist (mux.go). No PATCH/HEAD/OPTIONS/CONNECT/TRACE error-aware variants — those methods fall back to stdlib handlers. Add the rest (or a generic Method-style phi.Handler registrar) for consistency.

  • No graceful shutdown. Every service uses bare http.ListenAndServe; nofy-api has a // TODO: Gracefull shutdown comment. Consider a small phi.ListenAndServe/Serve helper with signal handling + http.Server.Shutdown(ctx).

  • Validate only checks presence. required flags 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-roll NotFound/Forbidden/Conflict values repeatedly. Add common ones (NotFound, Forbidden, BadRequest, Conflict).

  • Module versioning mismatch. Tags are v5.x (latest v5.2.5) but go.mod is module go.philip.id/phi without a /v5 suffix. Per Go module rules v2+ needs the major-version suffix in the module path. Verify this resolves correctly for consumers.

Docs (mostly addressed in the README rewrite)

  • 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 jwtauth subpackage API on its own (only referenced from middleware so far).
  • Document cors.Options fields (currently shown by example only).

Nice-to-have

  • 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.go exists; expand coverage to the response/error/context helpers.