router

package
v0.0.0-...-28d43d2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package router contains a flexible router, with integrated context management per request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Route

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

Route represents a Router matching rule, to be further refined.

func (*Route) Name

func (r *Route) Name(name string) *Route

Name assigns an identifier to the Route. This allows to use RouteFor to construct a path that could match this rule.

type Router

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

Router register routes to be matched and dispatches its corresponding handler. As the router accepts path arguments then it fills the context with the them.

func New

func New() *Router

New creates a new router, with the given ContextFactory

func (*Router) Delete

func (r *Router) Delete(path string, handler http.Handler) *Route

Delete register the handler in the router, after wrapping it with the middleware

func (*Router) DeleteFunc

func (r *Router) DeleteFunc(path string, handler http.HandlerFunc) *Route

DeleteFunc register the handler in the router, after wrapping it with the middleware

func (*Router) Get

func (r *Router) Get(path string, handler http.Handler) *Route

Get register the handler in the router, after wrapping it with the middleware

func (*Router) GetFunc

func (r *Router) GetFunc(path string, handler http.HandlerFunc) *Route

GetFunc register the handler in the router, after wrapping it with the middleware

func (*Router) HandleFunc

func (r *Router) HandleFunc(method string,
	path string,
	handler http.HandlerFunc) *Route

HandleFunc register a handler to be dispatched when a request matches with the method and the path.

func (*Router) Handler

func (r *Router) Handler(method string,
	path string,
	handler http.Handler) *Route

Handler register a handler to be dispatched when a request matches with the method and the path.

func (*Router) Options

func (r *Router) Options(path string, handler http.Handler) *Route

Options register the handler in the router, after wrapping it with the middleware

func (*Router) OptionsFunc

func (r *Router) OptionsFunc(path string, handler http.HandlerFunc) *Route

OptionsFunc register the handler in the router, after wrapping it with the middleware

func (*Router) Patch

func (r *Router) Patch(path string, handler http.Handler) *Route

Patch register the handler in the router, after wrapping it with the middleware

func (*Router) PatchFunc

func (r *Router) PatchFunc(path string, handler http.HandlerFunc) *Route

PatchFunc register the handler in the router, after wrapping it with the middleware

func (*Router) Post

func (r *Router) Post(path string, handler http.Handler) *Route

Post register the handler in the router, after wrapping it with the middleware

func (*Router) PostFunc

func (r *Router) PostFunc(path string, handler http.HandlerFunc) *Route

PostFunc register the handler in the router, after wrapping it with the middleware

func (*Router) Put

func (r *Router) Put(path string, handler http.Handler) *Route

Put register the handler in the router, after wrapping it with the middleware

func (*Router) PutFunc

func (r *Router) PutFunc(path string, handler http.HandlerFunc) *Route

PutFunc register the handler in the router, after wrapping it with the middleware

func (*Router) RouteFor

func (r *Router) RouteFor(name string, args ...string) string

RouteFor returns a route corresponding to the requested route name. The arguments have the format: RouteFor(name, [key, value]*)

func (*Router) ServeHTTP

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

ServeHTTP dispatches the handler that matches with the request

Jump to

Keyboard shortcuts

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