stdhttpserverfx

package
v0.0.187 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stdhttpserverfx provides a web server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	lc fx.Lifecycle,
	hdlr http.Handler,
	lnr *net.TCPListener,
	cfg Config,
	logs *zap.Logger,
) (*http.Server, error)

New inits the http server.

func Provide

func Provide(name ...string) fx.Option

Provide dependencies.

Types

type Config

type Config struct {
	// BindAddrPort configures where the web server will listen for incoming tcp traffic
	BindAddrPort string `env:"BIND_ADDR_PORT" envDefault:"0.0.0.0:8282"`
	// HTTP read timeout, See: https://blog.cloudflare.com/exposing-go-on-the-internet/
	ReadTimeout time.Duration `env:"READ_TIMEOUT" envDefault:"5s"`
	// HTTP read header timeout, See: https://blog.cloudflare.com/exposing-go-on-the-internet/
	ReadHeaderTimeout time.Duration `env:"READ_HEADER_TIMEOUT" envDefault:"5s"`
	// HTTP write timeout, See: https://blog.cloudflare.com/exposing-go-on-the-internet/
	WriteTimeout time.Duration `env:"WRITE_TIMEOUT" envDefault:"12s"`
	// HTTP idle timeout, See: https://blog.cloudflare.com/exposing-go-on-the-internet/
	IdleTimeout time.Duration `env:"IDLE_TIMEOUT" envDefault:"120s"`
}

Config configures the package.

Jump to

Keyboard shortcuts

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