hitch

package module
v0.0.0-...-bf92e60 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 2 Imported by: 42

README

Hitch

go get github.com/nbio/hitch

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

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. This is just a passthrough to httprouter.ParamsFromContext.

Types

type Hitch

type Hitch struct {
	Router *httprouter.Router
	// contains filtered or unexported fields
}

Hitch ties httprouter, context, 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 ...Middleware)

Delete registers a DELETE handler for the given path.

func (*Hitch) Get

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

Get registers a GET handler for the given path.

func (*Hitch) Handle

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

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 ...Middleware)

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

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 ...Middleware)

Options registers a OPTIONS handler for the given path.

func (*Hitch) Patch

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

Patch registers a PATCH handler for the given path.

func (*Hitch) Post

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

Post registers a POST handler for the given path.

func (*Hitch) Put

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

Put registers a PUT handler for the given path.

func (*Hitch) Use

func (h *Hitch) Use(middleware ...Middleware)

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.

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware wraps an http.Handler, returning a new http.Handler.

Jump to

Keyboard shortcuts

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