hitch

package module
v0.0.0-...-75253e8 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2018 License: MIT Imports: 3 Imported by: 0

README

Hitch

go get github.com/nbio/hitch

Hitch ties httprouter, httpcontext, and middleware up in a bow. Simple example.

Middleware

Middleware written for Hitch:

Author

© nb.io, LLC

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Params

func Params(req *http.Request) httprouter.Params

Params returns the httprouter.Params for req.

Types

type Hitch

type Hitch struct {
	Router     *httprouter.Router
	Middleware []func(http.Handler) http.Handler
}

Hitch ties httprouter, httpcontext, and middleware up in a bow.

func New

func New() *Hitch

New initializes a new Hitch.

func (*Hitch) Delete

func (h *Hitch) Delete(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Delete registers a DELETE handler for the given path.

func (*Hitch) Get

func (h *Hitch) Get(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Get registers a GET handler for the given path.

func (*Hitch) Handle

func (h *Hitch) Handle(method, path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Handle registers a handler for the given method and path.

func (*Hitch) HandleFunc

func (h *Hitch) HandleFunc(method, path string, handler func(http.ResponseWriter, *http.Request), middleware ...func(http.Handler) http.Handler)

HandleFunc registers a func handler for the given method and path.

func (*Hitch) HandleIf

func (h *Hitch) HandleIf(branch func(http.Handler, http.Handler) http.Handler, next http.Handler)

func (*Hitch) Handler

func (h *Hitch) Handler() http.Handler

Handler returns an http.Handler for the embedded router and middleware.

func (*Hitch) Next

func (h *Hitch) Next(handler http.Handler)

Next registers an http.Handler as a fallback/not-found handler.

func (*Hitch) Options

func (h *Hitch) Options(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Options registers a OPTIONS handler for the given path.

func (*Hitch) Patch

func (h *Hitch) Patch(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Patch registers a PATCH handler for the given path.

func (*Hitch) Post

func (h *Hitch) Post(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Post registers a POST handler for the given path.

func (*Hitch) Put

func (h *Hitch) Put(path string, handler http.Handler, middleware ...func(http.Handler) http.Handler)

Put registers a PUT handler for the given path.

func (*Hitch) Use

func (h *Hitch) Use(middleware ...func(http.Handler) http.Handler)

Use installs one or more middleware in the Hitch request cycle.

func (*Hitch) UseHandler

func (h *Hitch) UseHandler(handler http.Handler)

UseHandler registers an http.Handler as a middleware.

func (*Hitch) UseIf

func (h *Hitch) UseIf(cond func(req *http.Request) bool, handler http.Handler)

UseIf passes the request to handler only if cond meets

Jump to

Keyboard shortcuts

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