Files
web/server/server.go
T
Rene Nochebuena f0ff3c38ed docs(web): fix non-compiling doc examples; bump to v1.1.0 (#1)
Coordinated framework release. Documentation-only code changes plus the shared
version bump (folds the never-tagged 1.0.1 contracts pin into 1.1.0).

- mw.Recover() -> mw.Recover(logger): web/mw/doc.go, web/server/doc.go,
  web/server/server.go.
- health.NewHandler(...) -> ....ServeHTTP (chi Get takes HandlerFunc): web/server/doc.go,
  web/doc.go, web/health/doc.go.
- go.mod: contracts, core -> v1.1.0 (via go get + go mod tidy).

Verified by compiling the example patterns against the real API. Badge -> v1.1.0.

Reviewed-on: #1
Co-authored-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
Co-committed-by: Rene Nochebuena Guerrero <rene@nochebuena.dev>
2026-08-07 19:07:57 -06:00

38 lines
1005 B
Go

// Package server provides a lifecycle-managed chi HTTP server.
//
// The server implements [lifecycle.Component] from contracts, making it
// directly compatible with [launcher.New] without any adapter layer.
//
// # Example
//
// srv := server.New(logger, server.Config{Port: 8080},
// server.WithMiddleware(
// mw.Recover(logger),
// mw.RequestID(uuid.NewString),
// mw.RequestLogger(logger),
// ),
// )
//
// lc := launcher.New(logger)
// lc.Append(srv)
// lc.BeforeStart(func() error {
// srv.Get("/health", healthHandler)
// return nil
// })
package server
import (
"github.com/go-chi/chi/v5"
"code.nochebuena.dev/einherjar/contracts/lifecycle"
"code.nochebuena.dev/einherjar/contracts/observability"
)
// Server is a lifecycle-managed HTTP server that exposes a chi router.
// Embed chi.Router gives callers the full routing API: Get, Post, Route, Mount, Use, etc.
type Server interface {
lifecycle.Component
observability.Identifiable
chi.Router
}