http

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Healthz

func Healthz(w http.ResponseWriter, r *http.Request)

Healthz responds to an HTTP/S request with a 200 and content body "OK".

Types

type Filter

type Filter interface {
	// Decorate decorates one http.HandlerFunc with another.
	Decorate(http.HandlerFunc) http.HandlerFunc
}

Filter is an interface to be implemented by components that can decorate a http.HandlerFunc.

func NewIPFilter

func NewIPFilter(config IPFilterConfig) Filter

NewIPFilter returns a component that implements the Filter interface and can conditionally allow or disallow a request on the basis of the client's IP address.

type IPFilterConfig

type IPFilterConfig struct {
	// AllowedRanges are the IP ranges that are permitted to send requests.
	AllowedRanges []net.IPNet
}

IPFilterConfig encapsulates IPFilterConfig configuration.

type Server

type Server interface {
	// ListenAndServe runs the HTTP/S server until the provided context is
	// canceled. This function always returns a non-nil error.
	ListenAndServe(ctx context.Context) error
}

Server is an interface for an HTTP/S server. This is an improvement over the HTTP/S server built into Go's http package, as it exposes simple configuration options and a context-sensitive ListenAndServe function.

func NewServer

func NewServer(handler http.Handler, config *ServerConfig) Server

NewServer returns a new HTTP/S server.

type ServerConfig

type ServerConfig struct {
	// Port specifies the port the server should bind to / listen on.
	Port int
	// TLSEnabled specifies whether the server should serve HTTP (false) or HTTPS
	// (true).
	TLSEnabled bool
	// TLSCertPath is the path to a PEM-encoded x509 certificate that can be used
	// for serving HTTPS.
	TLSCertPath string
	// TLSKeyPath is the path to a PEM-encoded x509 private key that can be used
	// for serving HTTPS.
	TLSKeyPath string
}

ServerConfig represents optional configuration for an HTTP/S server.

Jump to

Keyboard shortcuts

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