http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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