sapp

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SDNotConfigured = errors.New("No SD registry has been configured.")

Functions

func ServeHTTPAndHTTPS

func ServeHTTPAndHTTPS(server *http.Server, l net.Listener) error

Serve HTTP and HTTPS on the same port.

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

func (s *Sapp) AclMiddleware(h http.Handler) http.Handler

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) Close

func (s *Sapp) Close() error

func (*Sapp) DefaultHandlers

func (s *Sapp) DefaultHandlers(srv *http.Server, health func() bool)

Set up default http handlers. health is optional. health checks if the application is healthy, returns false if it isn't.

func (*Sapp) DefaultServer

func (s *Sapp) DefaultServer() *http.Server

Returns a *http.Server suitable for SD queries.

func (*Sapp) Flags

func (s *Sapp) Flags(defaultConfPath string, parse bool)

Adds the default flags for all applications.

func (*Sapp) Init

func (s *Sapp) Init(app ...string) error

Initialize the application. Sets up plog, bconf and an fd_pool connected to service discovery.

func (*Sapp) Ready

func (s *Sapp) Ready() error

func (*Sapp) SDListener

func (s *Sapp) SDListener(n string, l net.Listener, useHttps bool)

SDListener registers this net.Listener in service discovery.

func (*Sapp) SDPort

func (s *Sapp) SDPort(n, v string, useHttps bool)

SDPort registers a port number in service discovery. This shouldn't be used unless there are no other options.

func (*Sapp) SDRegister

func (s *Sapp) SDRegister() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL