• v1.0.2 90cf1aab92

    Rene Nochebuena released this 2026-05-11 22:18:18 -06:00 | 0 commits to main since this release

    v1.0.2

    code.nochebuena.dev/go/httpmw

    Overview

    httpmw v1.0.2 commits the middleware API as stable. The module provides standalone
    net/http middleware functions for transport-layer concerns: panic recovery, CORS,
    request ID injection, and structured request logging. Each function is independent;
    no authentication or identity logic is included (see httpauth-firebase for that).

    What Changed Since v0.9.0

    Dependency bump

    logz promoted to v1.0.1. go directive updated to 1.26.

    No API changes. All middleware functions (Recover, CORS, RequestID,
    RequestLogger), the Logger interface, and StatusRecorder are unchanged.

    Full API (stable)

    Recover() func(http.Handler) http.Handler — catches panics, writes 500; zero
    configuration required.

    CORS(origins []string) func(http.Handler) http.Handler — sets
    Access-Control-Allow-* headers; responds 204 to OPTIONS preflight.

    RequestID(generator func() string) func(http.Handler) http.Handler — generates
    a request ID, injects it via logz.WithRequestID, sets X-Request-ID header.

    RequestLogger(logger Logger) func(http.Handler) http.Handler — logs method,
    path, status, latency, and request ID; uses Error for 5xx, Info for all others.

    Logger — duck-typed: Info(msg string, args ...any), Error(msg string, err error, args ...any), With(args ...any) Logger; satisfied by logz.Logger.

    StatusRecorder — exported http.ResponseWriter wrapper capturing the written
    status code in its Status field.

    Migration from v0.9.0

    No breaking changes. Drop-in replacement.

    go get code.nochebuena.dev/go/httpmw@v1.0.2
    
    Downloads