import "perkeep/pkg/webserver"
Overview ▹
Overview ▾
Package webserver implements a superset wrapper of http.Server.
Among other things, it can throttle its connections, inherit its listening socket from a file descriptor in the environment, and log all activity.
Index
- Variables
- type Server
- func New() *Server
- func (s *Server) Handle(pattern string, handler http.Handler)
- func (s *Server) HandleFunc(pattern string, fn func(http.ResponseWriter, *http.Request))
- func (s *Server) Listen(addr string) error
- func (s *Server) ListenURL() string
- func (s *Server) Serve()
- func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (s *Server) SetTLS(setup TLSSetup)
- type TLSSetup
Package files
Variables
var TailscaleCtxKey = ctxkey.New("tailscale", false)
TailscaleCtxKey is the context key for whether the server is running in Tailscale tsnet mode.
type Server
type Server struct {
Logger *log.Logger // or nil.
// H2Server is the HTTP/2 server config.
H2Server http2.Server
// contains filtered or unexported fields
}
func New
func New() *Server
func (*Server) Handle
func (s *Server) Handle(pattern string, handler http.Handler)
func (*Server) HandleFunc
func (s *Server) HandleFunc(pattern string, fn func(http.ResponseWriter, *http.Request))
func (*Server) Listen
func (s *Server) Listen(addr string) error
Listen starts listening on the given host:port addr.
If the "host" part is "tailscale", it goes into Tailscale tsnet mode, and the "port" is instead an optional state directory path or a bare name for the instance name.
func (*Server) ListenURL
func (s *Server) ListenURL() string
ListenURL returns the base URL of the server, including its scheme and authority, but without a trailing slash or any path.
func (*Server) Serve
func (s *Server) Serve()
func (*Server) ServeHTTP
func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*Server) SetTLS
func (s *Server) SetTLS(setup TLSSetup)
type TLSSetup
type TLSSetup struct {
// Certfile is the path to the TLS certificate file. It takes precedence over CertManager.
CertFile string
// KeyFile is the path to the TLS key file.
KeyFile string
// CertManager is the tls.GetCertificate of the tls Config. But CertFile takes precedence.
CertManager func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
}
TLSSetup specifies how the server gets its TLS certificate.
Subdirectories
| Name | Synopsis | |
|---|---|---|
| .. | ||
| listen |
