-
Release v0.9.0 Stable
released this
2026-03-19 07:40:35 -06:00 | 0 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