easytls

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 14 Imported by: 2

README

easy-tls

A set of packages for quickly and easily developing TLS-enabled Web Servers and Clients.

Documentation

Overview

Package easytls is intended to provide a simplification and abstraction layer for quickly creating HTTP(S) enabled web applications. This module intends to provide a simple API to illustrate the parameters needed for proper TLS security, as well as providing simpler methods for performing standard HTTP(S) operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandlers added in v1.0.1

func AddHandlers(verbose bool, s *SimpleServer, r *mux.Router, Handlers ...SimpleHandler)

AddHandlers will add the given handlers to the router, with the verbose flag determining if a log message should be generated for each added route.

func AddMiddlewares added in v1.0.1

func AddMiddlewares(r *mux.Router, middlewares ...MiddlewareHandler)

AddMiddlewares is a convenience wrapper for the mux.Router "Use" function

func DefaultLoggingMiddleware added in v1.0.1

func DefaultLoggingMiddleware(next http.Handler) http.Handler

DefaultLoggingMiddleware provides a simple logging middleware, to view incoming connections as they arrive.

func NewDefaultRouter added in v1.0.1

func NewDefaultRouter() *mux.Router

NewDefaultRouter will initialize a new HTTP Router, based on the gorilla/mux implementation.

func NewRouter added in v1.0.0

func NewRouter(s *SimpleServer, Handlers []SimpleHandler, Middlewares ...MiddlewareHandler) *mux.Router

NewRouter will build a new complex router, with the given routes, and middlewares. More can be added later, if needed.

func NewTLSConfig

func NewTLSConfig(TLS *TLSBundle) (*tls.Config, error)

NewTLSConfig will convert the TLSBundle, containing the filenames of the relevant certificates and Authorization policy, into a workable tls.Config object, ready to be used by either a Client or Server application.

Types

type KeyPair

type KeyPair struct {
	Certificate string
	Key         string
}

KeyPair represents the filenames to a pair of matching TLS Key/Certificate files.

type MiddlewareHandler added in v1.0.0

type MiddlewareHandler func(http.Handler) http.Handler

MiddlewareHandler represents the general format for a Middleware handler.

type SimpleClient added in v1.0.0

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

SimpleClient is a renaming of the Standard http.Client for this package, to allow the ease-of-use extensions provided here.

func NewClientHTTP added in v1.0.0

func NewClientHTTP() (*SimpleClient, error)

NewClientHTTP will create a new SimpleClient, with no TLS settings enabled. This will accept raw HTTP only.

func NewClientHTTPS added in v1.0.0

func NewClientHTTPS(TLS *TLSBundle) (*SimpleClient, error)

NewClientHTTPS will create a new TLS-Enabled SimpleClient. This will

func (*SimpleClient) Connect added in v1.0.0

func (C *SimpleClient) Connect(URL *url.URL, Headers map[string]string) error

Connect will (Not yet implemented)

func (*SimpleClient) Delete added in v1.0.0

func (C *SimpleClient) Delete(URL *url.URL, Headers map[string]string) error

Delete represents the abstraction of the HTTP Delete request, accounting for creating the request, setting headers, and asserting a valid status code. Closing the response body is the responsibility of this function.

func (*SimpleClient) Get added in v1.0.0

func (C *SimpleClient) Get(URL *url.URL, Headers map[string]string) (*http.Response, error)

Get represents the abstraction of the HTTP Get request, accounting for creating the request, setting headers, and asserting a valid status code. Closing the response body is the responsibility of the caller.

func (*SimpleClient) Head added in v1.0.0

func (C *SimpleClient) Head(URL *url.URL, Headers map[string]string) (http.Header, error)

Head represents the abstraction of the HTTP Head request, accounting for creating the request, setting headers, and asserting a valid status code. Closing the response body is the responsibility of this function, as Head only returns the headers.

func (*SimpleClient) Options added in v1.0.0

func (C *SimpleClient) Options(URL *url.URL, Headers map[string]string) error

Options will (Not yet implemented)

func (*SimpleClient) Patch added in v1.0.0

func (C *SimpleClient) Patch(URL *url.URL, Headers map[string]string) error

Patch will (Not yet implemented)

func (*SimpleClient) Post added in v1.0.0

func (C *SimpleClient) Post(URL *url.URL, contents io.Reader, Headers map[string]string) (*http.Response, error)

Post represents the abstraction of the HTTP Post request, accounting for creating the request, setting headers, and asserting a valid status code. Closing the response body is the responsibility of the caller.

func (*SimpleClient) Put added in v1.0.0

func (C *SimpleClient) Put(URL *url.URL, contents io.Reader, Headers map[string]string) error

Put represents the abstraction of the HTTP Put request, accounting for creating the request, setting headers, and asserting a valid status code. Closing the response body is the responsibility of this function.

func (*SimpleClient) Trace added in v1.0.0

func (C *SimpleClient) Trace(URL *url.URL, Headers map[string]string) error

Trace will (Not yet implemented)

type SimpleHandler added in v1.0.0

type SimpleHandler struct {
	Handler http.HandlerFunc
	Path    string
	Methods []string
}

SimpleHandler represents a simplification to the standard http handlerFuncs, allowing simpler registration and logging with Routers.

type SimpleServer added in v1.0.1

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

SimpleServer represents an extension to the standard http.Server

func NewServerHTTP added in v1.0.0

func NewServerHTTP(Addr string) (*SimpleServer, error)

NewServerHTTP will create a new http.Server, with no TLS settings enabled. This will accept raw HTTP only.

func NewServerHTTPS added in v1.0.0

func NewServerHTTPS(TLS *TLSBundle, Addr string) (*SimpleServer, error)

NewServerHTTPS will create a new TLS-Enabled http.Server. This will

func (*SimpleServer) EnableAboutHandler added in v1.0.4

func (S *SimpleServer) EnableAboutHandler(r *mux.Router)

EnableAboutHandler will enable and set up the "about" handler, to display the available routes. This must be the last route registered in order for the full set of routes to be displayed.

func (*SimpleServer) ListenAndServe added in v1.0.1

func (S *SimpleServer) ListenAndServe() error

ListenAndServe will start the SimpleServer, serving HTTPS if enabled, or HTTP if not

func (*SimpleServer) RegisterRouter added in v1.0.1

func (S *SimpleServer) RegisterRouter(r http.Handler)

RegisterRouter will register the given Handler (typically an *http.ServeMux or *mux.Router) as the http Handler for the server.

func (*SimpleServer) Shutdown added in v1.0.1

func (S *SimpleServer) Shutdown()

Shutdown will safely shut down the SimpleServer, returning any errors

type TLSBundle

type TLSBundle struct {
	AuthorityCertificates []string
	KeyPairs              []KeyPair
	Auth                  tls.ClientAuthType
	Enabled               bool
}

TLSBundle represents the set of TLS information required by Dune to assert 2-way TLS verification.

Jump to

Keyboard shortcuts

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