Documentation
¶
Overview ¶
Package server provides an HTTP/HTTPS server with graceful shutdown support, built on top of fasthttp.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunSignalHandler ¶
func RunSignalHandler(ctx context.Context, srv *Server, c *cache.Cache, cfgPath string, cfgPtr **config.Config, pc ...*security.PathCache)
RunSignalHandler blocks until SIGTERM or SIGINT is received, then gracefully shuts down srv. It also handles SIGHUP to reload configuration and flush cache.
Parameters:
- ctx: parent context (used to derive a shutdown context)
- srv: the running Server
- c: the cache to flush on SIGHUP
- cfgPath: path to the TOML config file (used for SIGHUP reload)
- cfgPtr: pointer to the current config pointer, updated on reload
- pc: optional path cache to flush on SIGHUP (may be nil)
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps one HTTP and one optional HTTPS fasthttp.Server.
func New ¶
func New(cfg *config.ServerConfig, secCfg *config.SecurityConfig, handler fasthttp.RequestHandler) *Server
New creates a Server from the provided configuration and handler. HTTPS is only configured when both TLSCert and TLSKey are non-empty. When TLS is configured, the HTTP server is replaced with a redirect handler that sends all requests to the HTTPS address (SEC-004).
Click to show internal directories.
Click to hide internal directories.