httputil

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: GPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertGenerator

type CertGenerator struct {
	Hosts          []string
	Organization   string
	NotBefore      time.Time
	NotAfter       time.Time
	CACertFile     string
	CAKeyFile      string
	ServerCertFile string
	ServerKeyFile  string
}

CertGenerator generates CA and server certificates for serving HTTPS.

func (*CertGenerator) Generate

func (g *CertGenerator) Generate() error

Generate creates the certificate files.

type Server

type Server struct {
	// Binding address for serving HTTP.
	Addr string
	// Binding address for serving HTTPS.
	AddrTLS string
	// Certificate file for HTTPS
	CertFile string
	// Private key file for HTTPS
	KeyFile string
	// When an error happens while serving (e.g. binding of port fails), this
	// error is sent to the channel ServeErr.
	ServeErr chan<- error
	// Default logger is "http-server", if not specified
	Log logging.Logger
	// contains filtered or unexported fields
}

Server is a plain http.Server with some usefull additions. The http.DefaultServeMux is used for the handlers.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown shuts the HTTP server down.

func (*Server) Startup

func (s *Server) Startup()

Startup starts the HTTP server.

type SingleAuthHandler

type SingleAuthHandler struct {
	http.Handler

	User     string
	Password string

	// Realm must only contain valid characters for an HTTP header value and no
	// double quotes.
	Realm string
}

SingleAuthHandler wraps another http.Handler and forces the specified authentication from the HTTP client.

func (*SingleAuthHandler) ServeHTTP

func (h *SingleAuthHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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