Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrPkg a common package error. ErrPkg = errors.New("server") // ErrServerUnableListenAndServe server error. ErrServerUnableListenAndServe = fmt.Errorf("%w: server unable to listen and serve", ErrPkg) // ErrServerCertificateDoesNotExist error. ErrServerCertificateDoesNotExist = fmt.Errorf("%w: certificate file does not exist", ErrPkg) // ErrServerKeyDoesNotExist error. ErrServerKeyDoesNotExist = fmt.Errorf("%w: key file does not exist", ErrPkg) // ErrServerUnableToMarshal error. ErrServerUnableToMarshal = fmt.Errorf("%w: unable to marshal", ErrPkg) // ErrServerShutdownFailure error. ErrServerShutdownFailure = fmt.Errorf("%w: unable to shutdown", ErrPkg) )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Port int `env:"PORT,default=8080" json:"port"`
ReadTimeout time.Duration `env:"READ_TIMEOUT,default=30s" json:"readTimeout"`
WriteTimeout time.Duration `env:"WRITE_TIMEOUT,default=30s" json:"writeTimeout"`
ErrorsBufferSize int `env:"ERRORS_BUFFER_SIZE,default=100" json:"errorsBufferSize"`
TLS *TLS `env:"TLS,prefix=TLS_" json:"tls"`
}
Config is a struct containing server configuration values.
type DefaultServer ¶
DefaultServer is a web server.
func New ¶
func New(options ...Option) *DefaultServer
New a factory function to create a new server.
func (*DefaultServer) Done ¶
func (s *DefaultServer) Done()
Done blocks until the server is fully stopped.
func (*DefaultServer) Errors ¶
func (s *DefaultServer) Errors() <-chan error
Errors subscribe to async errors.
type Option ¶
type Option func(p *DefaultServer)
Option function.
func WithShutdownFunc ¶
func WithShutdownFunc(function func()) Option
WithShutdownFunc configuration option.
Click to show internal directories.
Click to hide internal directories.