cfg

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServerConfig

type HTTPServerConfig struct {
	Port         string        // Port on which the server listens
	ReadTimeout  time.Duration // Maximum duration for reading the entire request
	WriteTimeout time.Duration // Maximum duration before timing out writes
	IdleTimeout  time.Duration // Maximum time to wait for the next request
}

HTTPServerConfig contains configuration settings for an HTTP server.

func LoadEnvHTTPServerConfig

func LoadEnvHTTPServerConfig() (*HTTPServerConfig, error)

LoadEnvHTTPServerConfig loads HTTP server configuration from environment variables. It expects the following environment variables to be set:

  • HTTPSERVER_PORT
  • HTTPSERVER_READ_TIMEOUT
  • HTTPSERVER_WRITE_TIMEOUT
  • HTTPSERVER_IDLE_TIMEOUT

The timeouts must be in valid Go duration format (e.g., "5s", "1m").

func NewHTTPServerConfig

func NewHTTPServerConfig(port string, read, write, idle time.Duration) *HTTPServerConfig

func (*HTTPServerConfig) WithIdleTimeout

func (cfg *HTTPServerConfig) WithIdleTimeout(timeout time.Duration) *HTTPServerConfig

WithIdleTimeout sets the IdleTimeout field and returns the config.

func (*HTTPServerConfig) WithPort

func (cfg *HTTPServerConfig) WithPort(port string) *HTTPServerConfig

WithPort sets the Port field and returns the config.

func (*HTTPServerConfig) WithReadTimeout

func (cfg *HTTPServerConfig) WithReadTimeout(timeout time.Duration) *HTTPServerConfig

WithReadTimeout sets the ReadTimeout field and returns the config.

func (*HTTPServerConfig) WithWriteTimeout

func (cfg *HTTPServerConfig) WithWriteTimeout(timeout time.Duration) *HTTPServerConfig

WithWriteTimeout sets the WriteTimeout field and returns the config.

Jump to

Keyboard shortcuts

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