http

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package http provides functionality to create http Clients/Servers. Configuration is done via protobuf messages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadAddr is returned when an address is invalid (e.g., it includes a port).
	ErrBadAddr = errors.New("bad address specified")

	// ErrMissingPort is returned if the port is required but not specified.
	ErrMissingPort = errors.New("no port specified")

	// ErrNoTLSConfig is returned if tls_config is not specified.
	ErrNoTLSConfig = errors.New("tls_config must be specified")

	// ErrNoCertFile is returned if cert_file is not specified.
	ErrNoCertFile = errors.New("tls_config.cert_file must be specified")

	// ErrNoKeyFile is returned if key_file is not specified.
	ErrNoKeyFile = errors.New("tls_config.key_file must be specified")
)

Functions

func NewClient

func NewClient(cfg *httppb.HttpTransport) (*http.Client, error)

NewClient generates an *http.Client from a config message.

func NoCache

func NoCache(w http.ResponseWriter)

NoCache is a helper to send no-cache headers to an *http.ResponseWriter.

func SetHSTS

func SetHSTS(w http.ResponseWriter, d time.Duration, subdomains bool)

SetHSTS is a helper to send HSTS headers to an *http.ResponseWriter.

Types

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request)

HandlerFunc is the function signature for an HTTP handler.

type Server

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

Server is a wrapper around *http.Server that enforces common settings.

func NewServer

func NewServer(cfg *httppb.HttpServerOptions) (*Server, error)

NewServer generates a *Server from a proto config message.

func (*Server) HandleFunc

func (s *Server) HandleFunc(pattern string, handler HandlerFunc)

HandleFunc registers the handler function for the given pattern: * Disables caching * Sets the HSTS policy, if hstsMaxAge > 0

func (*Server) Run

func (s *Server) Run() error

Run starts the HTTPS server.

Jump to

Keyboard shortcuts

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