Documentation ¶
Index ¶
Constants ¶
View Source
const (
ErrSiteExists = "site already exists"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Site ¶
type Site struct { // Domain to respond to. Domain string `json:"domain"` // Certificate PEM file to load. Absolute path. Certificate string `json:"certificate,omitempty"` // Key PEM file to load. Absolute path. Key string `json:"key,omitempty"` // Owner is a user in the database. Owner string `json:"owner"` // // Internals // log.LogShortcuts }
Site is the configuration for a specific domain.
func (*Site) DefaultHandler ¶
func (s *Site) DefaultHandler(w http.ResponseWriter, r *http.Request)
DefaultHandler for testing.
type Timeouts ¶ added in v0.6.0
type Timeouts struct { // Idle timeout defaults to 30 seconds. Idle time.Duration `json:"idle"` // Read timeout defaults to 10 seconds. Read time.Duration `json:"read"` // Write timeout defaults to 10 seconds. Write time.Duration `json:"write"` // Shutdown timeout defaults to 3 seconds. Shutdown time.Duration `json:"shutdown"` }
Timeouts for web server.
type Web ¶
type Web struct { sync.RWMutex sync.WaitGroup log.LogShortcuts http.Server // Address to bind the web server to. Address string `json:"address"` // Port is optional, and will default to 80 or 443, depending on presence of certificates. Port string `json:"port"` // SitePath is the directory where site configurations are stored. SitePath string `json:"sites"` // Secure servers prepare a default TLS configuration. Secure bool `json:"secure"` // Timeouts for connections and shutdown. Timeouts Timeouts `json:"timeouts"` // contains filtered or unexported fields }
Web server configuration and runtime data.
func New ¶
New creates a web server, configured with reasonable timeouts and a default handlers. Use AddSite() or LoadSites() to add handlers for domains.
func NewFromFile ¶ added in v0.5.0
NewFromFile creates a web server based on a JSON configuration file.
func (*Web) AddCertificate ¶
func (w *Web) AddCertificate(cert tls.Certificate)
AddCertificate from loaded certificate.
func (*Web) AddSite ¶
AddSite to a web server. This is done on the fly without need of any restarting.
func (*Web) LoadSites ¶ added in v0.5.0
LoadSites from JSON files in the site config directory (non-recursively).
func (*Web) RebuildCertificates ¶
RebuildCertificates reloads the certificates from all sites.
Click to show internal directories.
Click to hide internal directories.