httpserver

package
Version: v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultShutdownTimeout is the default ShutdownTimeout (see Config).
	DefaultShutdownTimeout = time.Second * 10
)

Variables

This section is empty.

Functions

func BaseTLSConfig added in v1.8.0

func BaseTLSConfig() *tls.Config

BaseTLSConfig returns a tls.Config with some good default settings for security.

Types

type Config

type Config struct {
	// Name is the name of the server. It is only used for logging. It can
	// be empty.
	Name string

	// Address is the address to bind the server to. It must be set.
	Address string

	// AddressTLS is the address to bind the https server to. It must be set, but is not used if TLS is not configured.
	AddressTLS string

	// TLSConfig is the TLS configuration for the server. It is optional.
	TLSConfig *TLSConfig

	// ShutdownTimeout controls how long to wait for requests to finish before
	// returning from Run() after the context is canceled. It defaults to
	// 10 seconds if unset. If set to a negative value, the server will be
	// closed immediately.
	ShutdownTimeout time.Duration
}

Config holds the HTTP server configuration.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the HTTP server.

architecture: Endpoint

func New

func New(log *zap.Logger, handler http.Handler, config Config) (*Server, error)

New creates a new URL Service Server.

func (*Server) Addr

func (server *Server) Addr() string

Addr returns the public address.

func (*Server) AddrTLS added in v1.4.0

func (server *Server) AddrTLS() string

AddrTLS returns the public TLS address.

func (*Server) Close added in v1.3.0

func (server *Server) Close() error

Close closes server.

func (*Server) Run

func (server *Server) Run(ctx context.Context) (err error)

Run runs the server until it's either closed or it errors.

type TLSConfig added in v1.4.0

type TLSConfig struct {
	LetsEncrypt bool
	CertFile    string
	KeyFile     string
	PublicURLs  []string
	ConfigDir   string
}

TLSConfig is a struct to handle the preferred/configured TLS options.

Source Files

Jump to

Keyboard shortcuts

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