Documentation ¶
Index ¶
- Variables
- type AutocertHandler
- type HTTP
- func (h *HTTP) AutocertHandler() AutocertHandler
- func (h *HTTP) IsRunning() bool
- func (h *HTTP) SecurityRedirects() []string
- func (h *HTTP) SetAutocertHandler(handler AutocertHandler)
- func (h *HTTP) SetSecurityRedirects(r []string)
- func (h *HTTP) Start(port int) error
- func (h *HTTP) Status() (bool, int)
- func (h *HTTP) Stop() error
- func (h *HTTP) Wait() error
- type HTTPS
- type KeyCert
- type Server
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyListening = errors.New("Already listening.") ErrInvalidPort = errors.New("Invalid port.") ErrNotListening = errors.New("Not listening.") ErrInvalidRootCA = errors.New("Invalid root CA.") )
Errors relating to HTTP or HTTPS servers.
Functions ¶
This section is empty.
Types ¶
type AutocertHandler ¶
type AutocertHandler func(w http.ResponseWriter, r *http.Request) bool
An AutocertHandler is a function which handles certain HTTP requests for ACME verification.
It returns false if the request was not handled.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is an HTTP server instance which can listen on one port at a time.
func NewHTTP ¶
NewHTTP creates a new HTTP server with a given handler. The server will not be started.
func (*HTTP) AutocertHandler ¶
func (h *HTTP) AutocertHandler() AutocertHandler
AutocertHandler returns the current AutocertHandler.
See SetAutocertHandler for more.
func (*HTTP) SecurityRedirects ¶
SecurityRedirects returns the list of hosts that are redirected to use a different amount of security. For HTTP servers, redirects go to HTTPS. For HTTPS servers, redirects go to HTTP.
The returned slice is a copy of the original, so the caller may modify it without changing the redirects used by the server.
func (*HTTP) SetAutocertHandler ¶
func (h *HTTP) SetAutocertHandler(handler AutocertHandler)
SetAutocertHandler sets the current AutocertHandler.
This is set on HTTP handlers to allow them to pass requests to an HTTPS handler.
func (*HTTP) SetSecurityRedirects ¶
SetSecurityRedirects sets the list of hosts that are redirected to use a different amount of security.
The slice is copied before being adopted by the server, so the caller may modify it without changing the redirects used by the server.
See SecurityRedirects for more.
func (*HTTP) Status ¶
Status returns whether or not the server is running and the port on which it is listening (if applicable).
type HTTPS ¶
type HTTPS struct { *HTTP // contains filtered or unexported fields }
HTTPS is an HTTPS server instance which can listen on one port at a time.
func NewHTTPS ¶
NewHTTPS creates a new HTTPS server with a given handler. The server will not be started.
func (*HTTPS) HandleAutocertRequest ¶
HandleAutocertRequest handles HTTP requests to verify with an ACME authority that we own a domain. If the request is not a verification request, false is returned and a downstream handler should be used.
func (*HTTPS) SetTLSConfig ¶
SetTLSConfig sets the TLSConfig on the server. This may stop and restart the server.
type Server ¶
type Server interface { // IsRunning returns true if the server is running. IsRunning() bool // Start starts the server if it is not running. Start(port int) error // Status returns the status of the server. // The first return value is the result of IsRunning(). // The second return value is the port on which the server is listenening if // it is running. Status() (bool, int) // Stop stops the server. Stop() error // Wait waits for the server to be stopped. Wait() error }
Server serves some sort of web content on a specified port.
type TLSConfig ¶
type TLSConfig struct { Named map[string]KeyCert `json:"named"` RootCAs []string `json:"root_ca"` Default KeyCert `json:"default"` ACMEDirectoryURL string `json:"acme_dir_url"` ACMEHosts []string `json:"acme_hosts"` ACMECacheDir string `json:"acme_cache_dir"` }
TLSConfig represents the TLS configuration for an HTTPS server.