Documentation ¶
Overview ¶
Package server is an extremely opinionated package for gluing together HTTP servers, managing their listeners, TLS certificates, domains, metrics and data dumps.
Index ¶
- Variables
- type HTTPOptions
- type Handlers
- type Options
- type Server
- func (s *Server) Serve() error
- func (s *Server) Shutdown(ctx context.Context)
- func (s *Server) Version() (v string)
- func (s *Server) WithDataDumpService(name string, service datadump.Interface)
- func (s *Server) WithHTTP(o HTTPOptions) (err error)
- func (s *Server) WithMetrics(cs ...prometheus.Collector)
- type TLSCert
Constants ¶
This section is empty.
Variables ¶
var ( DefaultIdleTimeout = 30 * time.Minute DefaultReadTimeout = 1 * time.Minute DefaultWriteTimeout = 1 * time.Minute )
Default values for HTTP server timeouts.
Functions ¶
This section is empty.
Types ¶
type HTTPOptions ¶
type HTTPOptions struct { Handlers Handlers Name string Listen string ListenTLS string TLSCerts []TLSCert IdleTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration }
HTTPOptions holds parameters for WithHTTP method. If timeouts are not set, package Default values will be used.
func (*HTTPOptions) SetHandler ¶
func (o *HTTPOptions) SetHandler(h http.Handler, domains ...string)
SetHandler sets an HTTP handler to serve specific domains.
type Options ¶
type Options struct { Name string Version string BuildInfo string ListenInstrumentation string ListenInstrumentationTLS string InstrumentationTLSCert string InstrumentationTLSKey string ACMECertsDir string ACMECertsEmail string SetupInstrumentationRouters func(base, api *http.ServeMux) Logger *slog.Logger EmailService *email.Service RecoveryService *recovery.Service MaintenanceService *maintenance.Service }
Options structure contains optional properties for the Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server contains all required properties, services and functions to provide core functionality.
func (*Server) WithDataDumpService ¶
WithDataDumpService adds a service with data dump interface to be used on instrumentation handler /data request.
func (*Server) WithHTTP ¶
func (s *Server) WithHTTP(o HTTPOptions) (err error)
WithHTTP add an HTTP server with a specific name, that listens for plain http or encrypted connections to the list of servers.
func (*Server) WithMetrics ¶
func (s *Server) WithMetrics(cs ...prometheus.Collector)
WithMetrics registers prometheus collector to be exposed on instrumentation handler /metrics request.