router

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle func(w http.ResponseWriter, r *http.Request, params Params)

Handle is a function that can be registered to a route to handle HTTP requests.

type Params added in v0.7.1

type Params map[string]string

Params is a map, as returned by the router.

type Router

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

Router is a http.Handler which can be used to dispatch requests to different handler functions.

func New

func New() *Router

New returns a new initialized Router.

func (*Router) Handle

func (router *Router) Handle(method string, path string, handle Handle)

Handle registers a new request handle with the given path and method.

func (*Router) NotFound

func (router *Router) NotFound(handle http.HandlerFunc)

Panic sets a NotFound handle.

func (*Router) Panic added in v0.7.1

func (router *Router) Panic(handle func(http.ResponseWriter, *http.Request, interface{}))

Panic sets a panic handle.

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

func (*Router) Validates added in v0.7.1

func (router *Router) Validates(validates Validates)

Validates sets param validates.

type Validate

type Validate func(s string) (ok bool)

Validate is a function to validate route params

type Validates added in v0.7.1

type Validates map[string]Validate

Validates is a Validate-map to validate router params.

Jump to

Keyboard shortcuts

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