mroute

package
v0.0.0-...-cb2c959 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRoutes

func HandleRoutes(r *mux.Router, routes map[string]Route)

HandleRoutes applies routes to a mux router. OPTIONS requests are handled, and the Access-Control-Allowed-Methods header is set. Middlewares are applied from the inside out (ex: cors, cache, auth would apply auth, then cors, then cache, then the handler).

func Multi

func Multi(routes map[string]http.Handler) http.Handler

Multi allows you to specify what handler should be used depending on the method. Note that a panic will occur if a request is given for a method that does not have a route.

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware functions wrap an http handler.

type Route

type Route struct {
	Handler     http.Handler
	Methods     []string
	Middlewares []Middleware
}

Route holds information for an HTTP route.

func Simple

func Simple(h http.Handler, method string, Middlewares ...Middleware) Route

Simple is a helper function that creates a route for just a single method.

Jump to

Keyboard shortcuts

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