server

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(cfg Config) error

ListenAndServe starts an HTTP server and blocks until SIGINT or SIGTERM is received. It then initiates a graceful shutdown, waiting up to ShutdownTimeout for active connections to finish.

func ListenAndServeMulti

func ListenAndServeMulti(services []ServiceConfig) error

ListenAndServeMulti starts multiple HTTP servers on separate ports and blocks until SIGINT/SIGTERM. All servers are shut down gracefully.

Types

type Config

type Config struct {
	Addr            string
	Handler         http.Handler
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	IdleTimeout     time.Duration
	ShutdownTimeout time.Duration
}

Config holds HTTP server settings.

type ServiceConfig

type ServiceConfig struct {
	Name   string // "web", "api", "ws" — for logging
	Config Config // Standard server config (addr, handler, timeouts)
}

ServiceConfig identifies a named HTTP service to run on a specific port.

Jump to

Keyboard shortcuts

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