# Changelog All notable changes to this module will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.9.2] - 2026-03-25 ### Fixed - `OnStart` now binds the TCP listener synchronously via `net.Listen` before launching the serve goroutine. A port-in-use (or any other bind) error is returned immediately from `OnStart`, 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. ## [0.9.1] - 2026-03-21 ### Fixed - `OnStop` now returns `nil` immediately when `s.srv == nil`, preventing a nil pointer panic when the launcher calls cleanup on a server component whose `OnStart` was never reached (e.g. because an earlier component failed during startup). ## [0.9.0] - 2026-03-18 ### Added - `Logger` interface — duck-typed; requires `Info(msg string, args ...any)` and `Error(msg string, err error, args ...any)`; satisfied directly by `logz.Logger` and by any two-method struct, with no import of `logz` required - `Config` struct — holds HTTP server configuration with env-tag support: `Host` (`SERVER_HOST`, default `0.0.0.0`), `Port` (`SERVER_PORT`, default `8080`), `ReadTimeout` (`SERVER_READ_TIMEOUT`, default `5s`), `WriteTimeout` (`SERVER_WRITE_TIMEOUT`, default `10s`), `IdleTimeout` (`SERVER_IDLE_TIMEOUT`, default `120s`) - `Option` functional option type for configuring the server at construction time - `WithMiddleware(mw ...func(http.Handler) http.Handler) Option` — accumulates middleware applied to the root chi router during `OnInit`; order is preserved and caller-controlled; multiple calls to `WithMiddleware` append to the list - `HttpServerComponent` interface — embeds both `launcher.Component` and `chi.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 - `New(logger Logger, cfg Config, opts ...Option) HttpServerComponent` — constructs the server component backed by `chi.NewRouter()`; no middleware is installed by default - `OnInit` lifecycle method — applies all middleware registered via `WithMiddleware` to the root router; no-op if none were provided - `OnStart` lifecycle method — constructs an `http.Server` with the configured timeouts and starts it in a background goroutine; logs the bind address on start and logs fatal errors if `ListenAndServe` exits unexpectedly - `OnStop` lifecycle method — calls `http.Server.Shutdown` with a 10-second context timeout, giving in-flight requests up to 10 seconds to complete before the method returns ### Design Notes - `HttpServerComponent` embeds `chi.Router` directly in the interface rather than delegating through wrapper methods, so callers register routes and manage the lifecycle on the same value with no extra indirection - No middleware is installed by default; the full middleware stack is composed explicitly via `WithMiddleware` at construction time, keeping the stack visible and ordering unambiguous in the application source - chi was chosen as the underlying router because it uses stdlib `http.Handler` throughout, making it fully compatible with `httpmw` middleware and `httputil` handler adapters without any wrapper code at the boundary [0.9.2]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.2 [0.9.1]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.1 [0.9.0]: https://code.nochebuena.dev/go/httpserver/releases/tag/v0.9.0