server

package
v0.0.0-...-70feec6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFlags

func RegisterFlags(fs *flag.FlagSet, c *Config)

Types

type Config

type Config struct {
	ListenAddress string
	EnableHTTP2   bool
	TLSConfig     TLSConfig
}

Config defines the web server configuration.

func DefaultConfig

func DefaultConfig(listenAddress string, enableTLS bool) Config

type Server

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

Server is a web server.

func NewServer

func NewServer(logger *slog.Logger, c *Config, handler http.Handler) (*Server, error)

NewServer initializes a web server with the given handler (typically an http.MuxServe).

func (*Server) Serve

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

Serve starts the web server. It will block until the server is shutted down or an error occurs.

func (*Server) Shutdown

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

Shutdown closes gracefully all active connections.

type TLSConfig

type TLSConfig struct {
	Enabled        bool
	CertFile       string
	KeyFile        string
	ClientCAFile   string
	MinVersion     string
	CipherSuites   operator.StringSet
	ReloadInterval time.Duration
}

TLSConfig defines the TLS settings of the web server.

func (*TLSConfig) Convert

func (tc *TLSConfig) Convert(logger *slog.Logger) (*tls.Config, error)

Convert returns a *tls.Config from the given TLSConfig. It returns nil when TLS isn't enabled/configured.

Jump to

Keyboard shortcuts

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