middleware

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: CC0-1.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(w http.ResponseWriter, r *http.Request) error

Handler is an injectable function which returns an error to help control flow.

type Middleware

type Middleware struct {
	*mux.Router
	// contains filtered or unexported fields
}

Middleware is a wrapper to make it easy to inject middleware in to the web application at different levels.

func New

func New(handler *mux.Router) *Middleware

New takes a mux.Router and prepares it as Middleware.

func NewRouter

func NewRouter() *Middleware

NewRouter will return Middleware with a new Gorilla mux.Router.

func (*Middleware) HandleFunc

func (m *Middleware) HandleFunc(path string, f http.HandlerFunc) *Middleware

HandleFunc takes a string to represent the path and an http.HandlerFunc. This function will then be wrapped with the middleware.

func (*Middleware) Inject

func (m *Middleware) Inject(f ...Handler) *Middleware

Inject takes one or more MiddlewareFunc's and appends them to the current collection.

func (*Middleware) PathPrefix

func (m *Middleware) PathPrefix(path string) *MiddlewareRoute

PathPrefix return a new MiddlewareRoute based on the path prefix.

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP can be passed to the http.ListenAndServe() function.

type MiddlewareRoute

type MiddlewareRoute struct {
	*mux.Route
	// contains filtered or unexported fields
}

MiddlewareRoute represents a route.

func (*MiddlewareRoute) Subrouter

func (mr *MiddlewareRoute) Subrouter() *Middleware

Subrouter creates a new Middleware router based on the route.

Jump to

Keyboard shortcuts

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