server

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingCACert = errors.New("missing required CA certificate")

ErrMissingCACert represents an error caused by server config that requires certificate verification, but is missing a CA certificate

Functions

func LoadCertPoolFromPkcs7Package

func LoadCertPoolFromPkcs7Package(pkcs7Package []byte) (*x509.CertPool, error)

LoadCertPoolFromPkcs7Package reads the certificates in a DER-encoded PKCS7 package and returns a newly-created x509.CertPool with those Certificates added.

func NamedServerFromContext

func NamedServerFromContext(ctx context.Context) string

NamedServerFromContext returns name name of the server that was previously added into the context, if any.

Types

type CreateNamedServerInput

type CreateNamedServerInput struct {
	Name         string
	Host         string
	Port         int
	Logger       *zap.Logger
	HTTPHandler  http.Handler
	ClientAuth   tls.ClientAuthType
	Certificates []tls.Certificate
	ClientCAs    *x509.CertPool // CaCertPool
}

CreateNamedServerInput contains the input for the CreateServer function.

type NamedServer

type NamedServer struct {
	*http.Server
	Name               string
	IsServerReady      bool
	IsServerReadyMutex sync.Mutex
}

NamedServer wraps *http.Server to override the definition of ListenAndServeTLS, but bypasses some restrictions.

func CreateNamedServer

func CreateNamedServer(input *CreateNamedServerInput) (*NamedServer, error)

CreateNamedServer returns a no-tls, tls, or mutual-tls Server based on the input given and an error, if any.

func (*NamedServer) IsReady

func (s *NamedServer) IsReady() bool

IsReady returns if a server is ready

func (*NamedServer) ListenAndServeTLS

func (s *NamedServer) ListenAndServeTLS() error

ListenAndServeTLS is similar to (*http.Server).ListenAndServeTLS, but bypasses some restrictions.

func (*NamedServer) Port

func (s *NamedServer) Port() int

Port returns the port the server binds to. Returns -1 if any error.

func (*NamedServer) WaitUntilReady

func (s *NamedServer) WaitUntilReady()

WaitUntilReady waits until the server is ready

Jump to

Keyboard shortcuts

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