Documentation ¶
Index ¶
- Variables
- func ServeHTTPAndHTTPS(server *http.Server, l net.Listener) error
- type Sapp
- func (s *Sapp) AclMiddleware(h http.Handler) http.Handler
- func (s *Sapp) Close() error
- func (s *Sapp) DefaultHandlers(srv *http.Server, health func() bool)
- func (s *Sapp) DefaultServer() *http.Server
- func (s *Sapp) Flags(defaultConfPath string, parse bool)
- func (s *Sapp) Init(app ...string) error
- func (s *Sapp) Ready() error
- func (s *Sapp) SDListener(n string, l net.Listener, useHttps bool)
- func (s *Sapp) SDPort(n, v string, useHttps bool)
- func (s *Sapp) SDRegister() error
- func (s *Sapp) WaitForShutdown()
Constants ¶
This section is empty.
Variables ¶
var SDNotConfigured = errors.New("No SD registry has been configured.")
Functions ¶
Types ¶
type Sapp ¶
type Sapp struct { // bconf accessible after initialization Bconf bconf.MutBconf // fd_pool accessible after initialization UseCPool bool Pool fd_pool.FdPoolConfig // TLS config read from config file during init, if any. For some reason // it doesn't work to use the same tls.Config for both the client and // the server. TlsConf *tls.Config TlsClientConf *tls.Config Acl acl.Acl // contains filtered or unexported fields }
func (*Sapp) AclMiddleware ¶
Add an ACL middleware to an http.Handler. The middleware will reject all requests which doesn't pass the ACL s.acl. This middleware is usually already installed by DefaultServer.
func (*Sapp) DefaultHandlers ¶
Set up default http handlers. health is optional. health checks if the application is healthy, returns false if it isn't.
func (*Sapp) DefaultServer ¶
Returns a *http.Server suitable for SD queries.
func (*Sapp) Init ¶
Initialize the application. Sets up plog, bconf and an fd_pool connected to service discovery.
func (*Sapp) SDListener ¶
SDListener registers this net.Listener in service discovery.
func (*Sapp) SDPort ¶
SDPort registers a port number in service discovery. This shouldn't be used unless there are no other options.
func (*Sapp) SDRegister ¶
SDRegister starts the process of registering to service discovery. Returns SDNotConfigured if no SD is available.
No actual data is added to service discovery until an actual port is added through SDListener and that listener socket starts answering healthcheck queries.
There is currently no way to indicate which port answers the healthcheck queries, the first one registered will be used.
func (*Sapp) WaitForShutdown ¶
func (s *Sapp) WaitForShutdown()
Wait until shutdown is complete. To ensure a graceful shutdown this function should be called after Server.Serve has returned http.ErrServerClosed.