Documentation
¶
Overview ¶
Package httpserverfx provides an fx module for HTTP server with Chi router.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Module = fx.Module( "httpserverfx", fx.Provide(provideConfiguration, NewHTTPServer), fx.Invoke(func(_ *http.Server) {}), )
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct {
Port uint16 `yaml:"port" env:"PORT,overwrite" validate:"required,gte=1,lte=65535"`
RequestTimeout uint8 `yaml:"request_timeout" env:"REQUEST_TIMEOUT,overwrite" validate:"required,gte=1,lte=120"`
ReadHeaderTimeout uint8 `yaml:"read_header_timeout" env:"READ_HEADER_TIMEOUT,overwrite" validate:"lte=120"`
ReadTimeout uint8 `yaml:"read_timeout" env:"READ_TIMEOUT,overwrite" validate:"lte=120"`
IdleTimeout uint16 `yaml:"idle_timeout" env:"IDLE_TIMEOUT,overwrite" validate:"lte=600"`
Cors CorsConfiguration `yaml:"cors" env:"CORS,overwrite"`
}
func (*Configuration) Validate ¶
func (c *Configuration) Validate() error
type CorsConfiguration ¶
type CorsConfiguration struct {
AllowedOrigins []string `yaml:"allowed_origins" env:"ALLOWED_ORIGINS,overwrite"`
AllowedMethods []string `yaml:"allowed_methods" env:"ALLOWED_METHODS,overwrite"`
AllowedHeaders []string `yaml:"allowed_headers" env:"ALLOWED_HEADERS,overwrite"`
AllowCredentials bool `yaml:"allow_credentials" env:"ALLOW_CREDENTIALS,overwrite"`
MaxAge int `yaml:"max_age" env:"MAX_AGE,overwrite" validate:"gte=0,lte=86400"`
}
type Result ¶
func NewHTTPServer ¶
type WithHTTPServer ¶
type WithHTTPServer interface {
HTTPServerConfiguration() *Configuration
}
Click to show internal directories.
Click to hide internal directories.