Bump logz dependency from v0.9.0 to v1.0.1 and update go directive from 1.25 to 1.26. API committed as stable; no code changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.8 KiB
2.8 KiB
Changelog
All notable changes to this module will be documented in this file.
The format is based on Keep a Changelog, and this module adheres to Semantic Versioning.
1.0.2 - 2026-05-12
Changed
logzdependency bumped from v0.9.0 to v1.0.1.godirective updated from 1.25 to 1.26.
0.9.0 - 2026-03-18
Added
Recover() func(http.Handler) http.Handler— catches panics from inner handlers viadefer/recover, captures the stack trace withdebug.Stack, and writes HTTP 500; requires no configuration or logger injectionCORS(origins []string) func(http.Handler) http.Handler— setsAccess-Control-Allow-Origin,Access-Control-Allow-Methods(GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS), andAccess-Control-Allow-Headers(Content-Type, Authorization, X-Request-ID) for matching origins; short-circuits OPTIONS preflight requests with HTTP 204; pass[]string{"*"}for development environmentsRequestID(generator func() string) func(http.Handler) http.Handler— callsgenerator(e.g.uuid.NewString) to produce a unique ID per request, stores it in the context vialogz.WithRequestID, and writes it to theX-Request-IDresponse headerRequestLogger(logger Logger) func(http.Handler) http.Handler— logs method, path, status code, latency, and request ID after the inner handler returns; useslogger.Errorfor 5xx responses andlogger.Infofor all others; reads the request ID from context vialogz.GetRequestIDLoggerinterface — duck-typed logger accepted byRequestLogger; satisfied bylogz.Logger:Info(msg string, args ...any),Error(msg string, err error, args ...any),With(args ...any) LoggerStatusRecorderstruct — exportedhttp.ResponseWriterwrapper that captures the written status code in itsStatusfield; used internally byRequestLoggerand available for custom logging middleware
Design Notes
RequestIDandRequestLoggeruselogz.WithRequestIDandlogz.GetRequestIDdirectly rather than a locally defined context key; this ensures the request ID is visible to anylogz.Loggerthat calls.WithContext(ctx)downstream, which would break if the key were re-implemented here.Recoverintentionally requires no logger injection in this release: it captures the stack trace but does not log it, keeping the middleware usable with zero configuration; logger injection is deferred to a future release.- No middleware is installed by default; the package exports independent functions and the application chooses the chain and order (recommended:
Recover→RequestID→RequestLogger→CORS).