Documentation
¶
Overview ¶
Package server owns Herald's HTTP lifecycle: it builds a TLS or plaintext listener from config, starts serving, and performs an ordered graceful shutdown (stop accepting -> drain in-flight -> flush audit writer -> shutdown tracer). Startup errors are returned to the caller instead of calling log.Fatal deep in the stack, so main can decide how to exit and tests can assert on failures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Addr is the listen address (e.g. ":8080").
Addr string
// LoopbackOnly rejects wildcard and non-loopback addresses. It is intended
// for administrative listeners that must never be publicly reachable.
LoopbackOnly bool
// TLSCertFile / TLSKeyFile enable TLS when both are set.
TLSCertFile string
TLSKeyFile string
// TLSClientCAFile enables mTLS (client certificate verification) when set.
// It requires TLSCertFile/TLSKeyFile.
TLSClientCAFile string
// ClientCertMode controls client certificate negotiation independently from
// request authentication: off, optional, or require.
ClientCertMode string
// ShutdownTimeout bounds the graceful drain window.
ShutdownTimeout time.Duration
Logger *logger.Logger
}
Config describes how to start the server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps a Fiber app plus its lifecycle configuration.
func New ¶
New validates the configuration and returns a Server. It returns an error (rather than aborting) for any misconfiguration so the caller controls exit.
func (*Server) OnShutdown ¶
func (s *Server) OnShutdown(h ShutdownHook)
OnShutdown registers a hook to run during graceful shutdown, after the HTTP server stops accepting connections.
func (*Server) Run ¶
Run starts the server and blocks until ctx is cancelled or the server exits with an error. On ctx cancellation it performs an ordered graceful shutdown. It returns nil on a clean shutdown.
func (*Server) TLSEnabled ¶
TLSEnabled reports whether the server will terminate TLS.
type ShutdownHook ¶
ShutdownHook runs during graceful shutdown. Hooks run in registration order after the HTTP server has stopped accepting new connections.