Documentation
¶
Overview ¶
Package server provides a production-ready HTTP server with graceful shutdown, signal handling, and lifecycle hooks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Server)
Option configures a Server.
func WithIdleTimeout ¶
WithIdleTimeout sets the idle timeout (default 120s).
func WithLogger ¶
WithLogger sets the structured logger (default slog.Default()).
func WithReadTimeout ¶
WithReadTimeout sets the read timeout (default 15s).
func WithShutdownTimeout ¶
WithShutdownTimeout sets the graceful shutdown timeout (default 30s).
func WithWriteTimeout ¶
WithWriteTimeout sets the write timeout (default 60s).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps http.Server with graceful shutdown and lifecycle hooks.
func (*Server) OnShutdown ¶
OnShutdown registers a hook that runs after HTTP connections are drained. Errors are logged but all hooks still execute.
func (*Server) OnStart ¶
OnStart registers a hook that runs before the server starts listening. If any hook returns an error, Start aborts and returns the error.