server

package
v0.0.0-...-ffdedf7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(cfg Config) (net.Listener, error)

Listen listens on the TCP network address addr and returns a net.Listener. If TLS is enabled, it listens for TLS connections.

func New

func New(cfg Config, log *slog.Logger, kafkaWriter *kafka.Writer, postgresPool *pgxpool.Pool) *http.Server

New returns a new HTTP server. It should be started with a listener returned by Listen.

Types

type Config

type Config struct {
	Host              string        `env:"HOST"` // default: "127.0.0.1"
	Port              int           `env:"PORT"` // default: 8080
	ReadHeaderTimeout time.Duration `env:"READ_HEADER_TIMEOUT"`
	TLS               TLSConfig     `envPrefix:"TLS_"`
}

Config holds the server configuration. The zero value is a valid configuration.

type TLSConfig

type TLSConfig struct {
	Enabled  bool   `env:"ENABLED"`
	CertFile string `env:"CERT_FILE"`
	KeyFile  string `env:"KEY_FILE"`
}

TLSConfig holds the TLS configuration. The zero value is a valid configuration.

Jump to

Keyboard shortcuts

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