Skip to content

v0.3.0 — form handling + config

Choose a tag to compare

@mikehelmick mikehelmick released this 13 Jun 23:16
· 98 commits to main since this release
064a424

Two composable, storage-free primitives that close the most central remaining SSR gap, while keeping the core lean (curated-toolkit philosophy — no ORM, no generators, nothing that forces a storage opinion).

✨ Highlights

form package (new)

The server-side parse → validate → re-render loop, previously fully manual.

  • form.Bind(r, dst) (Errors, error) — gorilla/schema binding + go-playground/validator tags, with errors keyed by the form field name so one name spans your HTML, binding, and errors.
  • Honest two-failure-mode contract: a non-nil error means an unprocessable request (respond 400); Errors.Any() means invalid user input (re-render with per-field errors and the user's input preserved).
  • Optional Validator hook for cross-field / bespoke rules the validate tags can't express (e.g. a must-accept-terms checkbox).
  • New dependencies are isolated to this package — the rest of the framework (and your secrets/keys builds) stays free of them, and cloud-isolation is unchanged.
type signup struct {
    Email string `form:"email" validate:"required,email"`
    Age   int    `form:"age"   validate:"gte=18"`
}

errs, err := form.Bind(r, &in)
if err != nil { response.BadRequest(w, r, renderer); return }   // unprocessable
if errs.Any() {                                                 // invalid input
    renderer.RenderHTMLStatus(w, http.StatusUnprocessableEntity, "signup",
        webctx.TemplateMap{"Form": in, "Errors": errs})
    return
}

Configuration via go-envconfig

  • No new package: logging.Config follows the existing secrets.Config / keys.Config env-tag pattern, and apps compose one config struct processed by a single envconfig.Process.
  • The example drops its hand-rolled env/envBool helpers in favor of a composed appConfig.

render

  • 422 Unprocessable Entity is now an allowed response code — the conventional status for a form that failed validation.

📚 Docs & example

  • New Forms and Configuration guides.
  • examples/ssr-oidc wires the full validated /submit loop (422 re-render with preserved input, success flash + redirect) and the composed config.

✅ Quality

  • Reviewed by parallel security / correctness / design agents across multiple models; govulncheck clean on both modules; cloud isolation preserved (form/logging/secrets = 0); go test -race, golangci-lint, and the docs build all green.

Full changelog: v0.2.0...v0.3.0