Documentation
¶
Index ¶
- Constants
- type Config
- type Handler
- type Service
- func (srv *Service) Run(ctx context.Context, workers ...Worker) error
- func (srv *Service) RunWorkers(ctx context.Context, workers ...Worker) error
- func (srv Service) ServeMux() *http.ServeMux
- func (srv Service) ServeMuxWithHandlers() http.Handler
- func (srv *Service) Use(handler Handler) *Service
- func (srv *Service) WithHTTPWorkers() *Service
- func (srv *Service) WithListener(listener net.Listener) *Service
- func (srv *Service) WithNWorkers(n int, worker Worker) *Service
- func (srv *Service) WithShutdown(worker Worker) *Service
- func (srv *Service) WithStatic(fSystem fs.FS) *Service
- func (srv *Service) WithVersion(version string) *Service
- func (srv *Service) WithWorkers(workers ...Worker) *Service
- type TLSConfig
- type VersionResponseConfig
- type Worker
Constants ¶
const AccessLogDisabled = "-"
AccessLogDisabled holds access_log value for access logging disabling.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Listen string `long:"listen" default:":8080" description:"Addr and port which server listens at" env:"LISTEN"`
MaxHeaderBytes int `long:"maxheader" description:"MaxHeaderBytes"`
ReadTimeout time.Duration `long:"rto" default:"10s" description:"HTTP read timeout"`
WriteTimeout time.Duration `long:"wto" default:"60s" description:"HTTP write timeout, '0' means disable"`
ReadHeaderTimeout time.Duration `long:"rhto" default:"10s" description:"HTTP read header timeout"`
IdleTimeout time.Duration `long:"ito" default:"10s" description:"HTTP idle timeout"`
GracePeriod time.Duration `long:"grace" default:"10s" description:"Stop grace period"`
IPHeader string `long:"ip_header" env:"IP_HEADER" default:"X-Real-IP" description:"HTTP Request Header for remote IP"`
UserHeader string `long:"user_header" env:"USER_HEADER" default:"X-Username" description:"HTTP Request Header for username"`
AccessLog string `long:"access_log" env:"ACCESS_LOG" description:"HTTP access log filename (default: STDOUT, '-' means disable)"`
UseETag bool `long:"etag" env:"ETAG" description:"Add ETAG in HTTP response"`
TLS TLSConfig `group:"HTTPS Options" namespace:"tls" env-namespace:"TLS"`
Version VersionResponseConfig `group:"Version response Options" namespace:"vr"`
}
Config holds all config vars.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds service attributes.
func (*Service) Run ¶
Run runs HTTP(s) service and workers. HTTP Workers will be registered if none.
func (*Service) RunWorkers ¶ added in v0.15.0
RunWorkers runs workers without HTTP service.
func (Service) ServeMuxWithHandlers ¶ added in v0.16.0
ServeMuxWithHandlers return mux joined with defined by Use handlers.
func (*Service) WithHTTPWorkers ¶ added in v0.16.0
WithHTTPWorkers registers HTTP workers.
func (*Service) WithListener ¶
WithListener sets service listener.
func (*Service) WithNWorkers ¶ added in v0.16.0
WithNWorkers registers N copies of worker.
func (*Service) WithShutdown ¶
WithShutdown registers worker for call on shutdown.
func (*Service) WithStatic ¶
WithStatic sets static filesystem for serve via http.
func (*Service) WithVersion ¶
WithVersion sets hanler returning source code version as js.
func (*Service) WithWorkers ¶ added in v0.16.0
WithWorkers registers workers.
type TLSConfig ¶ added in v0.13.0
type TLSConfig struct {
CertFile string `long:"cert" description:"CertFile for serving HTTPS instead HTTP" env:"CERT"`
KeyFile string `long:"key" description:"KeyFile for serving HTTPS instead HTTP" env:"KEY"`
NoCheckCertificate bool `long:"no-check" description:"disable tls certificate validation"`
}
TLSConfig holds TLS config options.
type VersionResponseConfig ¶ added in v0.13.0
type VersionResponseConfig struct {
Prefix string `long:"prefix" default:"/js/version.js" description:"URL for version response"`
Format string `` /* 161-byte string literal not displayed */
CType string `long:"ctype" default:"text/javascript" description:"js code Content-Type header"`
}
VersionResponseConfig holds settings for HTTP version response.