Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ComponentContextKey = "component"
ComponentContextKey is a key for the Request context that returns the Component instance serving the request.
Functions ¶
func ForceSecureMiddleware ¶
ForceSecureMiddleware will redirect requests to their HTTPS equivalent if HTTPS has been configured for the component.
Types ¶
type Component ¶
type Component struct { Log log.Logger `com:"singleton"` Handlers []Handler `com:"extpoint"` Middleware MiddlewareInjector `com:"singleton"` Config // contains filtered or unexported fields }
Component for web serving
func FromRequest ¶
func (*Component) InitializeConfig ¶
InitializeConfig sets up defaults and unmarshals into Config embedded in Component
func (*Component) InitializeDaemon ¶
InitializeDaemon will attempt to setup a TLSCertReloader if TLSCertPath is configured.
func (*Component) Serve ¶
func (c *Component) Serve()
Serve starts listening and serving HTTP and HTTPS if configured
type Config ¶
type Config struct { // Address and port to listen on ListenAddr string // Directory to serve static files from StaticDir string // URL path to serve static files at StaticPath string // Random string to use for session cookies CookieSecret string // Address and port to listen for TLS on TLSAddr string // Path to TLS cert file TLSCertPath string // Path to TLS key file TLSKeyPath string }
Config is the configuration for Component
type Handler ¶
type Handler interface { // MatchHTTP returns true when a Request should be handled by this object MatchHTTP(r *http.Request) bool // ServeHTTP handles the Request if MatchHTTP returns true ServeHTTP(w http.ResponseWriter, r *http.Request) }
Handler extension API for matching and handling HTTP requests
type MiddlewareInjector ¶
type MiddlewareInjector interface { // Middleware returns a list of middleware in the order of outer first Middleware() []Middleware }
MiddlewareInjector defines ordered HTTP middleware to use
type TLSCertReloader ¶
TLSCertReloader is a TLS certificate provider that can reload certificates from disk. This is used when a TLS cert is configured, with Reload called once an hour. This means updating the cert and key on disk will start being used within an hour without needing to restart the server.
func NewTLSCertReloader ¶
func NewTLSCertReloader(certPath, keyPath string) (*TLSCertReloader, error)
NewTLSCertReloader returns a new NewTLSCertReloader after an initial call to Reload, which could return an error.
func (*TLSCertReloader) GetCertificate ¶
func (cr *TLSCertReloader) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate is used with tls.Config to provide a tls.Certificate
func (*TLSCertReloader) Reload ¶
func (cr *TLSCertReloader) Reload() error
Reload performs a simple tls.LoadX509KeyPair with the given paths and atomically makes it available via the
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
init
Package init is used to register the auth component with the default registry via side effect import.
|
Package init is used to register the auth component with the default registry via side effect import. |
init
Package init is used to register the console component with the default registry via side effect import.
|
Package init is used to register the console component with the default registry via side effect import. |
Package init is used to register the web component with the default registry via side effect import.
|
Package init is used to register the web component with the default registry via side effect import. |
init
Package init is used to register the sessions component with the default registry via side effect import.
|
Package init is used to register the sessions component with the default registry via side effect import. |