Documentation
¶
Index ¶
- type HTTPServerConfig
- func (cfg *HTTPServerConfig) WithIdleTimeout(timeout time.Duration) *HTTPServerConfig
- func (cfg *HTTPServerConfig) WithPort(port string) *HTTPServerConfig
- func (cfg *HTTPServerConfig) WithReadTimeout(timeout time.Duration) *HTTPServerConfig
- func (cfg *HTTPServerConfig) WithWriteTimeout(timeout time.Duration) *HTTPServerConfig
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.
Click to show internal directories.
Click to hide internal directories.