• v1.0.2 9b6608418b

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

    v1.0.2

    code.nochebuena.dev/go/httpserver

    Overview

    httpserver v1.0.2 commits the HTTP server API as stable and adds configurable
    graceful-shutdown timeout. The module wraps chi's router in a launcher.Component
    lifecycle with synchronous port binding, guard against nil server on stop, and a
    duck-typed Logger interface satisfied by logz.Logger.

    What Changed Since v0.9.2

    Configurable ShutdownTimeout

    Config gains a ShutdownTimeout time.Duration field (SERVER_SHUTDOWN_TIMEOUT,
    default 10s). Previously the graceful-shutdown deadline was hardcoded to 10 seconds.
    Callers serving long-running requests (file uploads, streaming) or preferring a shorter
    fail-fast window can now set this per environment without code changes.

    // Default: 10s — no change required for existing deployments
    cfg := httpserver.Config{}
    
    // Override via env or struct literal
    cfg.ShutdownTimeout = 30 * time.Second
    

    Dependency bumps

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

    Full API (stable)

    ConfigHost, Port, ReadTimeout, WriteTimeout, IdleTimeout,
    ShutdownTimeout; all settable via SERVER_* environment variables.

    Logger — duck-typed: Info(msg string, args ...any), Error(msg string, err error, args ...any).

    Option — functional option type.

    WithMiddleware(mw ...func(http.Handler) http.Handler) Option — accumulates middleware
    applied to the router during OnInit; order preserved; multiple calls append.

    HttpServerComponent — embeds launcher.Component and chi.Router; callers get the
    full chi routing API (Get, Post, Route, Mount, Use, With, Group, etc.) on
    the same value that participates in the launcher lifecycle.

    New(logger Logger, cfg Config, opts ...Option) HttpServerComponent — constructor;
    no middleware installed by default.

    Migration from v0.9.2

    No breaking changes. ShutdownTimeout defaults to 10s — existing deployments behave
    identically without any config change.

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