Documentation
¶
Index ¶
- func ListenAndServeTLSWithTimeouts(addr, certFile, keyFile string, handler http.Handler) error
- func ListenAndServeWithTimeouts(addr string, handler http.Handler) error
- func Shutdown(ctx context.Context) error
- type ServerBase
- func (a *ServerBase) DefaultHandler() http.Handler
- func (a *ServerBase) HSTSHandler(next http.Handler) http.Handler
- func (a *ServerBase) Init(self ServerBaseI)
- func (a *ServerBase) MakeHandler() http.Handler
- func (a *ServerBase) ServeAppMux(next http.Handler) http.Handler
- func (a *ServerBase) ServePatternMux(next http.Handler) http.Handler
- type ServerBaseI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServeTLSWithTimeouts ¶
ListenAndServeTLSWithTimeouts starts a secure web server with timeouts. The default http server does not have timeouts by default, which leaves the server open to certain attacks that would start a connection, but then very slowly read or write. Timeout values are taken from global variables defined in config, which you can set at init time.
func ListenAndServeWithTimeouts ¶
ListenAndServeWithTimeouts starts a web server with timeouts. The default http server does not have timeouts, which leaves the server open to certain attacks that would start a connection, but then very slowly read or write. Timeout values are taken from global variables defined in config, which you can set at init time. This non-secure version is appropriate if you are serving behind another server, like apache or nginx.
Types ¶
type ServerBase ¶
func (*ServerBase) DefaultHandler ¶
func (a *ServerBase) DefaultHandler() http.Handler
DefaultHandler is the last handler on the default call chain. It returns a simple not found error. Note that the html root handler registered in embedder.go also handles situations where an http path is not found. You can override this handler by duplicating it in your app object.
func (*ServerBase) HSTSHandler ¶
func (a *ServerBase) HSTSHandler(next http.Handler) http.Handler
HSTSHandler sets the browser to HSTS mode using the given timeout. HSTS will force a browser to accept only HTTPS connections for everything coming from your domain, if the initial page was served over HTTPS. Many browsers already do this. What this additionally does is prevent the user from overriding this. Also, if your certificate is bad or expired, it will NOT allow the user the option of using your website anyway. This should be safe to send in development mode if your local server is not using HTTPS, since the header is ignored if a page is served over HTTP.
Once the HSTS policy has been sent to the browser, it will remember it for the amount of time specified, even if the header is not sent again. However, you can override it by sending another header, and clear it by setting the timeout to 0. Set the timeout to -1 to turn it off. You can also completely override this by implementing this function in your app.go file.
func (*ServerBase) Init ¶
func (a *ServerBase) Init(self ServerBaseI)
func (*ServerBase) MakeHandler ¶
func (a *ServerBase) MakeHandler() http.Handler
func (*ServerBase) ServeAppMux ¶
func (a *ServerBase) ServeAppMux(next http.Handler) http.Handler
ServeAppMux serves up the http2.AppMuxer, which handles REST calls, and dynamically created files.
To use your own AppMuxer, override this function in app.go and create your own.
func (*ServerBase) ServePatternMux ¶
func (a *ServerBase) ServePatternMux(next http.Handler) http.Handler
ServePatternMux serves up the http2.PatternMuxer.
The pattern muxer routes patterns early in the handler stack. It is primarily for handlers that do not need the session manager or buffered output, things like static files.
The default version injects a standard http muxer. Override to use your own muxer.