Commit Graph
13 Commits
Author SHA1 Message Date
Rene Nochebuena d40ba7441e release: v1.7.1 (coordinated lockstep bump) 2026-08-18 18:44:15 -06:00
Rene Nochebuena 304dd18828 release: v1.7.0 (lockstep); generalize ADR-001 (drop private consumer name) 2026-08-18 17:55:35 -06:00
Rene Nochebuena e76dc48688 docs(adr): generalize ADR-001 motivation — drop private consumer name and its internal ADR reference
The framework ADR must be self-contained: it described the motivating failure
modes by naming a specific downstream service and one of its internal ADRs, which
no framework reader has context for. Reworded to 'a downstream service' and to the
general authorization-boundary rationale.
2026-08-14 01:08:36 -06:00
Rene Nochebuena a778227fc2 feat(httputil): add Bind/BindEmpty request binding from path and query; v1.6.0
Bind and BindEmpty fill Req from path/query/json struct tags and validate
once, extending the typed decode->validate->call->encode pipeline to routes
with identifiers and filters. Conversion via builtins + encoding.TextUnmarshaler
(uuid.UUID, time.Time); malformed value -> 400 naming the parameter; default:
applies only when absent; repeated query -> slice; mis-tagged struct panics at
wiring. Purely additive; existing adapters unchanged. Coordinated lockstep v1.6.0.
2026-08-13 23:11:23 -06:00
Rene Nochebuena bcccfef443 feat(web): httputil.WithStatus — configurable success status on the handler adapters (v1.5.0) 2026-08-12 17:55:28 -06:00
Rene Nochebuena 80b28dfcc4 feat(web): add mw.RequestIDFrom (resolver sees the request); dependency refresh; v1.4.0 2026-08-12 15:27:32 -06:00
Rene Nochebuena 929fafcfa5 feat(web)!: remove web.Config.AllowedOrigins; CORS lives only on server.Config.CORSOrigins (v1.3.0) 2026-08-08 10:48:00 -06:00
Rene Nochebuena c611e67946 feat(web): move CORSOrigins to server.Config; web.New warns on empty CORS; align to v1.2.0 2026-08-08 02:24:08 -06:00
Rene Nochebuena fc3fe750d4 docs(web): document CORS wildcard rejection + env-gated convention; align to v1.1.3 2026-08-08 01:26:17 -06:00
Rene Nochebuena 8876af3bfa fix(web): mw.CORS rejects wildcard; fix README fences; align to v1.1.2 2026-08-08 00:43:09 -06:00
Rene Nochebuena c6a753e49b chore(web): framework version alignment to v1.1.1 2026-08-07 23:32:09 -06:00
Rene Nochebuena f0ff3c38ed docs(web): fix non-compiling doc examples; bump to v1.1.0 (#1)
Coordinated framework release. Documentation-only code changes plus the shared
version bump (folds the never-tagged 1.0.1 contracts pin into 1.1.0).

- mw.Recover() -> mw.Recover(logger): web/mw/doc.go, web/server/doc.go,
  web/server/server.go.
- health.NewHandler(...) -> ....ServeHTTP (chi Get takes HandlerFunc): web/server/doc.go,
  web/doc.go, web/health/doc.go.
- go.mod: contracts, core -> v1.1.0 (via go get + go mod tidy).

Verified by compiling the example patterns against the real API. Badge -> v1.1.0.

Reviewed-on: #1
Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
2026-08-07 19:07:57 -06:00
Rene Nochebuena c4ef1948f6 feat(web): initial implementation — server, mw, httputil, health (v1.0.0)
Introduces code.nochebuena.dev/einherjar/web — the HTTP transport layer of the
Einherjar framework. Absorbs httpserver, httpmw, and httputil from micro-lib,
replacing gorilla/mux with chi, adopting SecurityBag-native middleware, and
centralizing error handling through a single httputil.Error function.

server:
- Server interface — embeds lifecycle.Component and chi.Router
- Config struct (EINHERJAR_SERVER_* env vars); DefaultConfig
- New(logger, cfg, opts...) Server; WithMiddleware option
- Binds TCP synchronously in OnStart; logs "server: listening" on success
- Graceful shutdown within ShutdownTimeout on OnStop

mw:
- Recover — catches panics, returns 500, logs at Error
- RequestID — injects UUID v7 (UUID v4 fallback) into context and X-Request-ID header
- RequestLogger — structured access log per request
- CORS / CORSAllowAll — chi-based, applied only when origins non-empty
- IPRateLimit / UserRateLimit — pluggable RateLimiterStore interface
- InMemoryRateLimiterStore — token-bucket backed by golang.org/x/time/rate;
  background goroutine evicts stale entries every 5 minutes
- StatusRecorder — wraps ResponseWriter to capture HTTP status code

httputil:
- Handle[Req, Res] / HandleNoBody[Res] / HandleEmpty[Req] — generic handler adapters
- Error(logger, w, r, err) — derives log level from status (≥500→Error, 4xx→Warn,
  499→Info); writes standardized JSON body; logz enriches *xerrors.Err automatically
- JSON(w, status, v) / NoContent(w) — response helpers
- HandlerFunc adapter type

health:
- NewHandler / NewHandlerWithConfig — runs all Checkable checks concurrently;
  returns JSON {status, components} with per-component latency and error
- Config struct (EINHERJAR_HEALTH_CHECK_TIMEOUT, default 5s)

Root factory:
- web.New(logger, cfg...) Server — composes Recover+RequestID+RequestLogger+CORS
  in outermost-first order; CORS applied only when AllowedOrigins non-empty

- server.Server interface and web/server/identifiable.go: embeds observability.Identifiable;
  ModulePath and ModuleVersion read via runtime/debug.ReadBuildInfo() — prints in launcher banner
2026-05-29 15:48:11 +00:00