Documentation ¶
Overview ¶
Package https provides a helper for starting an HTTPS server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAutocertCacheMiss = autocert.ErrCacheMiss
ErrAutocertCacheMiss is a copy of the autocert.ErrCacheMiss variable that must be used by any AutocertCache implementations used in the Options struct. This is because the autocert package is vendored by the upspin.io repository, and so an outside implementation that returns ErrCacheMiss from another version of the package will return an error value that is not recognized by the autocert package.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(ready chan<- struct{}, opt *Options)
ListenAndServe serves the http.DefaultServeMux by HTTPS (and HTTP, redirecting to HTTPS) using the provided options.
The given channel, if any, is closed when the TCP listener has succeeded. It may be used to signal that the server is ready to start serving requests.
ListenAndServe does not return. It exits the program when the server is shut down (via SIGTERM or due to an error) and calls shutdown.Shutdown.
func ListenAndServeFromFlags ¶
func ListenAndServeFromFlags(ready chan<- struct{})
ListenAndServeFromFlags is the same as ListenAndServe, but it determines the listen address and Options from command-line flags in the flags package.
Types ¶
type AutocertCache ¶
AutocertCache is a copy of the autocert.Cache interface, provided here so that implementers need not import the autocert package directly. See ErrAutocertCacheMiss for more details.
type Options ¶
type Options struct { // Addr specifies the host and port on which the server should serve // HTTPS requests (or HTTP requests if InsecureHTTP is set). // If empty, ":443" is used. Addr string // HTTPAddr specifies the host and port on which the server should // serve HTTP requests. If empty and InsecureHTTP is true, Addr is // used. If empty otherwise, ":80" is used. HTTPAddr string // AutocertCache provides a cache for use with Let's Encrypt. // If non-nil, enables Let's Encrypt certificates for this server. // See the comment on ErrAutocertCacheMiss before usin this feature. AutocertCache AutocertCache // LetsEncryptCache specifies the cache file for Let's Encrypt. // If non-empty, enables Let's Encrypt certificates for this server. LetsEncryptCache string // LetsEncryptHosts specifies the list of hosts for which we should // obtain TLS certificates through Let's Encrypt. If LetsEncryptCache // is specified this should be specified also. LetsEncryptHosts []string // CertFile and KeyFile specifies the TLS certificates to use. // It has no effect if LetsEncryptCache is non-empty. CertFile string KeyFile string // InsecureHTTP specifies whether to serve insecure HTTP without TLS. // An error occurs if this is attempted with a non-loopback address. InsecureHTTP bool }
Options permits the configuration of TLS certificates for servers running outside GCE. The default is the self-signed certificate in upspin.io/rpc/testdata.
func OptionsFromFlags ¶
func OptionsFromFlags() *Options
OptionsFromFlags returns Options derived from the command-line flags present in the upspin.io/flags package.