-
Release v1.0.2 Stable
released this
2026-05-11 22:18:25 -06:00 | 0 commits to main since this releasev1.0.2
code.nochebuena.dev/go/httpserverOverview
httpserverv1.0.2 commits the HTTP server API as stable and adds configurable
graceful-shutdown timeout. The module wraps chi's router in alauncher.Component
lifecycle with synchronous port binding, guard against nil server on stop, and a
duck-typedLoggerinterface satisfied bylogz.Logger.What Changed Since v0.9.2
Configurable
ShutdownTimeoutConfiggains aShutdownTimeout time.Durationfield (SERVER_SHUTDOWN_TIMEOUT,
default10s). 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.SecondDependency bumps
launcherandlogzpromoted to v1.0.1.godirective updated to 1.26.Full API (stable)
Config—Host,Port,ReadTimeout,WriteTimeout,IdleTimeout,
ShutdownTimeout; all settable viaSERVER_*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 duringOnInit; order preserved; multiple calls append.HttpServerComponent— embedslauncher.Componentandchi.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.
ShutdownTimeoutdefaults to10s— existing deployments behave
identically without any config change.go get code.nochebuena.dev/go/httpserver@v1.0.2Downloads
-
Release v0.9.2 Stable
released this
2026-03-24 18:53:56 -06:00 | 1 commits to main since this releasev0.9.2
code.nochebuena.dev/go/httpserverOverview
Patch release. Fixes a silent failure in
OnStartwhere a port-in-use error was
swallowed inside a goroutine, leaving the application running without an HTTP server
instead of failing fast.What's Changed
Fixed
OnStartnow binds the TCP listener synchronously vianet.Listenbefore
launching the serve goroutine. A port-in-use (or any other bind) error is
returned immediately fromOnStart, allowing the launcher to treat it as a
fatal startup failure and trigger a clean shutdown. Previously the error only
appeared in a log line while the application continued running without an
HTTP server.
Installation
go get code.nochebuena.dev/go/httpserver@v0.9.2Requires
code.nochebuena.dev/go/launcherandgithub.com/go-chi/chi/v5.Full Changelog
https://code.nochebuena.dev/go/httpserver/compare/v0.9.1...v0.9.2
Downloads
-
Release v0.9.1 Stable
released this
2026-03-21 10:53:55 -06:00 | 3 commits to main since this releasev0.9.1
code.nochebuena.dev/go/httpserverOverview
Patch release. Fixes a nil pointer panic in
OnStopthat occurred when the launcher
called cleanup on an httpserver component whoseOnStarthad never run — typically
because an earlier component (e.g. the database) failed during startup.What's Fixed
OnStopnil guards.srv(the*http.Server) is assigned only insideOnStart. In v0.9.0,OnStop
calleds.srv.Shutdown(ctx)unconditionally, panicking with a nil pointer dereference
whenever the launcher triggered cleanup beforeOnStarthad executed.v0.9.1 adds an early return:
func (s *httpServer) OnStop() error { if s.srv == nil { return nil } ... }No interfaces, configuration, or public API are changed.
Upgrade
go get code.nochebuena.dev/go/httpserver@v0.9.1Requires no code changes. Drop-in replacement for v0.9.0.
v0.9.0
code.nochebuena.dev/go/httpserverOverview
httpserverprovides a lifecycle-managed HTTP server built on chi v5. It implements
launcher.Component(OnInit → OnStart → OnStop) and embedschi.Routerdirectly,
so a single value serves both as a lifecycle component and as the router for all route
registration.This release reflects an API designed through multiple architecture reviews and
validated end-to-end via the todo-api POC. It is versioned at v0.9.0 rather than
v1.0.0 because it has not yet been exercised in production workloads across all edge
cases, preserving the option for minor API refinements before committing to full
stability.What's Included
New(logger Logger, cfg Config, opts ...Option) HttpServerComponentConstructs the server component. No middleware is installed by default; the full
middleware stack is composed explicitly at construction time viaWithMiddleware.HttpServerComponentinterfaceEmbeds both
launcher.Componentandchi.Router, giving callers the complete chi
routing API (Get,Post,Route,Mount,Use,With,Group, etc.) on the
same value that participates in the launcher lifecycle.ConfigstructField Env var Default HostSERVER_HOST0.0.0.0PortSERVER_PORT8080ReadTimeoutSERVER_READ_TIMEOUT5sWriteTimeoutSERVER_WRITE_TIMEOUT10sIdleTimeoutSERVER_IDLE_TIMEOUT120sWithMiddleware(mw ...func(http.Handler) http.Handler) OptionAccumulates middleware applied to the root router during
OnInit. Order is
preserved and caller-controlled.LoggerinterfaceDuck-typed: requires only
Info(msg string, args ...any)and
Error(msg string, err error, args ...any).logz.Loggersatisfies this directly.Lifecycle
OnInit— applies registered middleware to the routerOnStart— startshttp.ListenAndServein a background goroutineOnStop— callshttp.Server.Shutdownwith a 10-second context timeout; in-flight requests have up to 10 seconds to complete
Installation
go get code.nochebuena.dev/go/httpserver@v0.9.0Requires
code.nochebuena.dev/go/launcherandgithub.com/go-chi/chi/v5.Design Highlights
chi over other frameworks. chi uses stdlib
http.Handlereverywhere. Every
middleware in the micro-lib stack (httpmw) and every handler adapter (httputil)
useshttp.Handler/http.ResponseWriter/*http.Requestnatively. No wrapper
code is required at any boundary.Embedded
chi.Router.HttpServerComponentembedschi.Routerdirectly in the
interface. Callers get the full routing API without delegation or wrapper methods.
Route registration and lifecycle management happen on the same value.No default middleware.
New()installs nothing. The middleware stack is composed
explicitly withWithMiddleware(...)at construction time, keeping the stack visible
and ordering unambiguous in the application source.Duck-typed Logger. The two-method
Loggerinterface avoids a hard dependency on
logz. Any struct withInfoandErrormethods satisfies it, including test stubs
and application-local adapters.Known Limitations & Edge Cases
- No TLS/HTTPS support. The server binds with
http.ListenAndServeonly. TLS
termination is expected at the infrastructure layer (reverse proxy, load balancer). - The graceful shutdown drain timeout (10 seconds) is hardcoded in
OnStopand is
not configurable viaConfigorOption. Long-running streaming requests may be
cut short if they exceed this window. - Middleware registered via
srv.Use(mw)afterOnInithas run may not behave as
expected depending on chi's internal router state. All middleware should be
provided viaWithMiddlewareat construction time.
v0.9.0 → v1.0.0 Roadmap
- Make the graceful shutdown timeout configurable (e.g.,
WithShutdownTimeout) - Evaluate optional TLS support via a
WithTLS(certFile, keyFile string) Option - Production hardening: validate behavior under high concurrency and slow-client scenarios
- Consider exposing a
ServeHTTPmethod to enable embedding the server in test suites without binding a real port
Downloads
-
Release v0.9.0 Stable
released this
2026-03-19 07:40:35 -06:00 | 4 commits to main since this releasev0.9.0
code.nochebuena.dev/go/httpserverOverview
httpserverprovides a lifecycle-managed HTTP server built on chi v5. It implements
launcher.Component(OnInit → OnStart → OnStop) and embedschi.Routerdirectly,
so a single value serves both as a lifecycle component and as the router for all route
registration.This release reflects an API designed through multiple architecture reviews and
validated end-to-end via the todo-api POC. It is versioned at v0.9.0 rather than
v1.0.0 because it has not yet been exercised in production workloads across all edge
cases, preserving the option for minor API refinements before committing to full
stability.What's Included
New(logger Logger, cfg Config, opts ...Option) HttpServerComponentConstructs the server component. No middleware is installed by default; the full
middleware stack is composed explicitly at construction time viaWithMiddleware.HttpServerComponentinterfaceEmbeds both
launcher.Componentandchi.Router, giving callers the complete chi
routing API (Get,Post,Route,Mount,Use,With,Group, etc.) on the
same value that participates in the launcher lifecycle.ConfigstructField Env var Default HostSERVER_HOST0.0.0.0PortSERVER_PORT8080ReadTimeoutSERVER_READ_TIMEOUT5sWriteTimeoutSERVER_WRITE_TIMEOUT10sIdleTimeoutSERVER_IDLE_TIMEOUT120sWithMiddleware(mw ...func(http.Handler) http.Handler) OptionAccumulates middleware applied to the root router during
OnInit. Order is
preserved and caller-controlled.LoggerinterfaceDuck-typed: requires only
Info(msg string, args ...any)and
Error(msg string, err error, args ...any).logz.Loggersatisfies this directly.Lifecycle
OnInit— applies registered middleware to the routerOnStart— startshttp.ListenAndServein a background goroutineOnStop— callshttp.Server.Shutdownwith a 10-second context timeout; in-flight requests have up to 10 seconds to complete
Installation
go get code.nochebuena.dev/go/httpserver@v0.9.0Requires
code.nochebuena.dev/go/launcherandgithub.com/go-chi/chi/v5.Design Highlights
chi over other frameworks. chi uses stdlib
http.Handlereverywhere. Every
middleware in the micro-lib stack (httpmw) and every handler adapter (httputil)
useshttp.Handler/http.ResponseWriter/*http.Requestnatively. No wrapper
code is required at any boundary.Embedded
chi.Router.HttpServerComponentembedschi.Routerdirectly in the
interface. Callers get the full routing API without delegation or wrapper methods.
Route registration and lifecycle management happen on the same value.No default middleware.
New()installs nothing. The middleware stack is composed
explicitly withWithMiddleware(...)at construction time, keeping the stack visible
and ordering unambiguous in the application source.Duck-typed Logger. The two-method
Loggerinterface avoids a hard dependency on
logz. Any struct withInfoandErrormethods satisfies it, including test stubs
and application-local adapters.Known Limitations & Edge Cases
- No TLS/HTTPS support. The server binds with
http.ListenAndServeonly. TLS
termination is expected at the infrastructure layer (reverse proxy, load balancer). - The graceful shutdown drain timeout (10 seconds) is hardcoded in
OnStopand is
not configurable viaConfigorOption. Long-running streaming requests may be
cut short if they exceed this window. - Middleware registered via
srv.Use(mw)afterOnInithas run may not behave as
expected depending on chi's internal router state. All middleware should be
provided viaWithMiddlewareat construction time.
v0.9.0 → v1.0.0 Roadmap
- Make the graceful shutdown timeout configurable (e.g.,
WithShutdownTimeout) - Evaluate optional TLS support via a
WithTLS(certFile, keyFile string) Option - Production hardening: validate behavior under high concurrency and slow-client scenarios
- Consider exposing a
ServeHTTPmethod to enable embedding the server in test suites without binding a real port
Downloads