route

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Method

func Method(method ...string) []string

func NewStaticHandle

func NewStaticHandle(root string) http.Handler

Types

type Compiled

type Compiled struct {
	Regex string
}

type Request

type Request interface {
	GetMethod() string
	GetPath() string
}

type Route

type Route struct {
	Rules   map[string][]*Rule
	Current *Rule
}

func NewRoute

func NewRoute() *Route

func (*Route) Add

func (r *Route) Add(method []string, pattern string, handler interface{})

Add Add a route to the Router.Rules

func (*Route) Any

func (r *Route) Any(pattern string, handler interface{})

Any Register a new rule responding to all verbs.

func (*Route) Delete

func (r *Route) Delete(pattern string, handler interface{})

Delete Register a new DELETE rule with the router.

func (*Route) Dispatch

func (r *Route) Dispatch(request Request) (*Rule, error)

Dispatch Dispatch the request to the application.

func (*Route) Get

func (r *Route) Get(pattern string, handler interface{})

Get Register a new GET rule with the router.

func (*Route) Head

func (r *Route) Head(pattern string, handler interface{})

Head Register a new Head rule with the router.

func (*Route) Match

func (r *Route) Match(request Request) (*Rule, error)

Match Find the first rule matching a given request.

func (*Route) Options

func (r *Route) Options(pattern string, handler interface{})

Options Register a new OPTIONS rule with the router.

func (*Route) Patch

func (r *Route) Patch(pattern string, handler interface{})

Patch Register a new PATCH rule with the router.

func (*Route) Post

func (r *Route) Post(pattern string, handler interface{})

Post Register a new POST rule with the router.

func (*Route) Put

func (r *Route) Put(pattern string, handler interface{})

Put Register a new PUT rule with the router.

func (*Route) Static

func (r *Route) Static(path, root string)

func (*Route) Statics

func (r *Route) Statics(statics map[string]string)

type Rule

type Rule struct {
	Method         []string
	Pattern        string
	Handler        interface{}
	ParameterNames []string
	Parameters     map[string]string
	Compiled       *Compiled
}

Rule Route rule

func (*Rule) Bind

func (r *Rule) Bind(path string)

Bind Bind the route to a given request for execution.

func (*Rule) GetParameterNames

func (r *Rule) GetParameterNames() []string

GetParameterNames Get all of the parameter names for the rule.

func (*Rule) Matches

func (r *Rule) Matches(method, path string) bool

Matches Determine if the rule matches given request.

Jump to

Keyboard shortcuts

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