Documentation
¶
Index ¶
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 ¶
type ServerBase struct {
// HstsMaxAge sets the HSTS timeout length in seconds.
// Set this to -1 to turn off HSTS, or 0 to reset it.
HstsMaxAge int64
HstsIncludeSubdomains bool
HstsPreload bool
SessionHandler session.ManagerI
}
func (*ServerBase) Init ¶
func (a *ServerBase) Init()
func (*ServerBase) MakeHandler ¶
func (a *ServerBase) MakeHandler() http.Handler
func (*ServerBase) SetupMessenger ¶
func (a *ServerBase) SetupMessenger()
SetupMessenger injects the global messenger that permits pub/sub communication between the server and client.
You can use this mechanism to set up your own messaging system for application use too.
func (*ServerBase) SetupSessionManager ¶
func (a *ServerBase) SetupSessionManager()
SetupSessionManager sets up the global session manager. The session can be used to save data that is specific to a user and specific to the user's time on a browser. Sessions are often used to save login credentials so that you know the current user is logged in.
The default uses a 3rd party session manager, stores the session in memory, and tracks sessions using cookies. This setup is useful for development, testing, debugging, and for moderately used websites. However, this default does not scale, so if you are launching multiple copies of the app in production, you should override this with a scalable storage mechanism.
func (*ServerBase) WithHsts ¶
func (a *ServerBase) WithHsts(next http.Handler) http.Handler
WithHsts adds an HSTS middleware to the handler stack.
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.
func (*ServerBase) WithSession ¶
func (a *ServerBase) WithSession(next http.Handler) http.Handler
WithSession puts the session handling middleware into the handler stack
type ServerBaseI ¶
type ServerBaseI interface {
Init()
}
ServerBaseI defines the virtual functions that are callable on the Server.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assets contains the css and javascript required to run a goradd server.
|
Package assets contains the css and javascript required to run a goradd server. |
|
Package config contains configurable default values for various aspects of goradd.
|
Package config contains configurable default values for various aspects of goradd. |
|
Package log controls how logging
|
Package log controls how logging |
|
Package messageServer implements a general purpose messaging platform based on the gorilla websocket implementation.
|
Package messageServer implements a general purpose messaging platform based on the gorilla websocket implementation. |
|
location
Package location implements a location queue built on top of the session service.
|
Package location implements a location queue built on top of the session service. |