router

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

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

Go to latest
Published: Jul 16, 2018 License: MIT Imports: 4 Imported by: 2

README

router

router module for NovaKit

Documentation

Index

Constants

View Source
const ContextPathParamsKey = "_path_params"

ContextPathParamsKey key for path params in request.Context()

Variables

This section is empty.

Functions

func PathParams

func PathParams(c *nova.Context) (u url.Values)

PathParams extract path parameters from nova.Context

Types

type HeaderRule

type HeaderRule struct {
	Name  string
	Value []string
}

HeaderRule route rule with header restriction

func (HeaderRule) Match

func (r HeaderRule) Match(c *nova.Context) bool

Match implements Rule

type HostRule

type HostRule struct {
	Host []string
}

HostRule route rule with host restriction

func (HostRule) Match

func (r HostRule) Match(c *nova.Context) bool

Match implements Rule

type MethodRule

type MethodRule struct {
	Method []string
}

MethodRule route rule with method restriction

func (MethodRule) Match

func (r MethodRule) Match(c *nova.Context) bool

Match implements Rule

type PathRule

type PathRule struct {
	Path string
}

PathRule route rule with path restriction and params extraction

func (PathRule) Match

func (r PathRule) Match(c *nova.Context) bool

Match implements Rule

type Router

type Router struct {
	Nova  *nova.Nova
	Rules Rules
}

Router router

func Route

func Route(n *nova.Nova) Router

Route create a Router on nova application

func (Router) Delete

func (h Router) Delete(path string) Router

Delete shortcut for .Method("DELETE").Path(...)

func (Router) Get

func (h Router) Get(path string) Router

Get shortcut for .Method("GET").Path(...)

func (Router) Header

func (h Router) Header(name string, value ...string) Router

Header add header restriction

func (Router) Host

func (h Router) Host(host ...string) Router

Host add host restriction

func (Router) Method

func (h Router) Method(method ...string) Router

Method add method restriction

func (Router) Patch

func (h Router) Patch(path string) Router

Patch shortcut for .Method("PATCH").Path(...)

func (Router) Path

func (h Router) Path(path string) Router

Path add path restriction

func (Router) Post

func (h Router) Post(path string) Router

Post shortcut for .Method("POST").Path(...)

func (Router) Put

func (h Router) Put(path string) Router

Put shortcut for .Method("PUT").Path(...)

func (Router) Rule

func (h Router) Rule(r Rule) Router

Rule make a clone of Router and append a Rule

func (Router) Use

func (h Router) Use(handlers ...nova.HandlerFunc) Router

Use complete the handler and register to *arc.Arc, then create a empty Router

type Rule

type Rule interface {
	// Match match the http.Request, returns if matched
	Match(c *nova.Context) bool
}

Rule is a single rule in a route

type Rules

type Rules []Rule

Rules a slice of Rule, with nil-safe methods

func (Rules) Add

func (rs Rules) Add(rule Rule) Rules

Add create a copy of Rules with new rule added

func (Rules) Match

func (rs Rules) Match(c *nova.Context) bool

Match match all rules against request

Jump to

Keyboard shortcuts

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