Documentation ¶
Overview ¶
Package httputil contains a HTTP/HTTPS Server which can be stopped via signals or a Shutdown() call.
Index ¶
Constants ¶
const SigShutdown = 1
SigShutdown is used to signal a request for shutdown
Variables ¶
var ErrSigShutdown = errors.New("Server was shut down")
ErrSigShutdown indicates that a signal was received
Functions ¶
func CheckLocalRedirect ¶
CheckLocalRedirect checks if a given redirect URL is a local redirect. The function returns an error in all other cases.
func RandomFileServer ¶
RandomFileServer returns a handler that serves all HTTP requests with the contents of a random file. The file is picked from a predefined list.
Types ¶
type HTTPServer ¶
type HTTPServer struct { LastError error // Last recorded error Running bool // Flag if the server is running // contains filtered or unexported fields }
HTTPServer data structure
func (*HTTPServer) RunHTTPSServer ¶
func (hs *HTTPServer) RunHTTPSServer(keypath string, certFile string, keyFile string, laddr string, wgStatus *sync.WaitGroup) error
RunHTTPSServer starts a HTTPS Server which can be stopped via ^C (Control-C). It is assumed that all routes have been added prior to this call.
keypath should be set to a path containing the TLS certificate and key. certFile should be the file containing the TLS certificate. keyFile should be the file containing the private key for the TLS connection. laddr should be the local address which should be given to net.Listen. wgStatus is an optional wait group which will be notified once the server is listening and once the server has shutdown.
This function will not return unless the server is shutdown.
func (*HTTPServer) RunHTTPServer ¶
func (hs *HTTPServer) RunHTTPServer(laddr string, wgStatus *sync.WaitGroup) error
RunHTTPServer starts a HTTP Server which can be stopped via ^C (Control-C). It is assumed that all routes have been added prior to this call.
laddr should be the local address which should be given to net.Listen. wgStatus is an optional wait group which will be notified once the server is listening and once the server has shutdown.
This function will not return unless the server is shutdown.
Directories ¶
Path | Synopsis |
---|---|
Package access contains access control code for webservers.
|
Package access contains access control code for webservers. |
Package auth contains user authentication code for webservers.
|
Package auth contains user authentication code for webservers. |
Package user contains user session management for webservers.
|
Package user contains user session management for webservers. |