muxinator

package
v0.0.0-...-3f24e04 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Middleware replicates the negroni.HandlerFunc type but decouples the code from the library

type Router

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

Router is a wrapper around the gorilla mux router and the negroni middleware library. It has some convenience functions to make it easier to do per-route middleware

func NewRouter

func NewRouter() Router

NewRouter returns a new Router instance with some defaults

func (*Router) AddMiddleware

func (router *Router) AddMiddleware(middlewares ...Middleware)

AddMiddleware adds middleware that will be applied to every request. Middleware handlers are executed in the order defined.

func (*Router) BuildHandler

func (router *Router) BuildHandler() http.Handler

BuildHandler returns an http.Handler that can be used as the argument to http.ListenAndServe.

func (*Router) Delete

func (router *Router) Delete(path string, handler http.HandlerFunc, middlewares ...Middleware)

Delete is a helper function to add a DELETE route

func (*Router) Get

func (router *Router) Get(path string, handler http.HandlerFunc, middlewares ...Middleware)

Get is a helper function to add a GET route

func (*Router) ListenAndServe

func (router *Router) ListenAndServe(addr string) error

ListenAndServe builds the final handler and passes it to http.ListenAndServe

func (*Router) Patch

func (router *Router) Patch(path string, handler http.HandlerFunc, middlewares ...Middleware)

Patch is a helper function to add a PATCH route

func (*Router) Post

func (router *Router) Post(path string, handler http.HandlerFunc, middlewares ...Middleware)

Post is a helper function to add a POST route

func (*Router) Put

func (router *Router) Put(path string, handler http.HandlerFunc, middlewares ...Middleware)

Put is a helper function to add a PUT route

Jump to

Keyboard shortcuts

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