server

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultShutdownTimeout = 30 * time.Second

DefaultShutdownTimeout is the default timeout for graceful shutdown.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr            string
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	IdleTimeout     time.Duration
	ShutdownTimeout time.Duration
	TLSEnabled      bool
	TLSCertFile     string
	TLSKeyFile      string
}

Config holds the configuration for an HTTP server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wraps an HTTP server with lifecycle management.

func New

func New(cfg Config, handler http.Handler, logger *slog.Logger) *Server

New creates a new Server with the given configuration and handler. If ShutdownTimeout is not set, DefaultShutdownTimeout is used.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server and blocks until the context is cancelled. It handles graceful shutdown when the context is done.

Directories

Path Synopsis
mcp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL