router2

package
v5.0.0-...-beacedc Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2014 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	POST verb = 1 << iota
	GET
	PUT
	DELETE
	PATCH
	OPTIONS
)

Variables

This section is empty.

Functions

func NewRoute

func NewRoute() *route

Types

type MountedRouter

type MountedRouter struct {
	*PathNode

	NotFound http.Handler
	// contains filtered or unexported fields
}

func Mount

func Mount(path string, r *Router) (*MountedRouter, error)

func MustMount

func MustMount(path string, r *Router) *MountedRouter

func (*MountedRouter) MustURL

func (ø *MountedRouter) MustURL(rt *route, params ...string) string

func (*MountedRouter) MustURLMap

func (ø *MountedRouter) MustURLMap(rt *route, params map[string]string) string

func (*MountedRouter) MustURLStruct

func (ø *MountedRouter) MustURLStruct(rt *route, paramStruct interface{}, tagKey string) string

func (*MountedRouter) Path

func (ø *MountedRouter) Path() string

func (*MountedRouter) Serve404

func (ø *MountedRouter) Serve404(w http.ResponseWriter, r *http.Request)

func (*MountedRouter) ServeHTTP

func (ø *MountedRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MountedRouter) URL

func (ø *MountedRouter) URL(rt *route, params ...string) (string, error)

params are key/value pairs

func (*MountedRouter) URLMap

func (ø *MountedRouter) URLMap(rt *route, params map[string]string) (string, error)

params are key/values

func (*MountedRouter) URLStruct

func (ø *MountedRouter) URLStruct(rt *route, paramStruct interface{}, tagKey string) (string, error)

type PathLeaf

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

For the route /admin/forums/:forum_id:\d.*/suggestions/:suggestion_id:\d.* We'd have wildcards = ["forum_id", "suggestion_id"] For the route /admin/forums/:forum_id/suggestions/:suggestion_id:\d.* We'd have wildcards = ["forum_id", "suggestion_id"] For the route /admin/forums/:forum_id/suggestions/:suggestion_id We'd have wildcards = ["forum_id", "suggestion_id"]

func (PathLeaf) AddHandlerX

func (r PathLeaf) AddHandlerX(handler http.Handler, v verb) error

func (PathLeaf) Handler

func (r PathLeaf) Handler(v string) http.Handler

func (PathLeaf) Inspect

func (r PathLeaf) Inspect(indent int) string

type PathNode

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

func (*PathNode) Inspect

func (pn *PathNode) Inspect(indent int) string

func (*PathNode) Match

func (pn *PathNode) Match(path string) (leaf *PathLeaf, wildcards map[string]string)

type Router

type Router struct {
	NotFound http.Handler
	// contains filtered or unexported fields
}

func New

func New(wrapper ...rack.Wrapper) (ø *Router)

func (*Router) DELETE

func (r *Router) DELETE(path string, handler http.Handler) *route

func (*Router) GET

func (r *Router) GET(path string, handler http.Handler) *route

func (*Router) Handle

func (ø *Router) Handle(path string, v verb, handler http.Handler) (*route, error)

func (*Router) Mount

func (ø *Router) Mount(path string, m *http.ServeMux) (*MountedRouter, error)

func (*Router) MustHandle

func (r *Router) MustHandle(path string, v verb, handler http.Handler) *route

func (*Router) MustMount

func (r *Router) MustMount(path string, m *http.ServeMux) *MountedRouter

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handler http.Handler) *route

func (*Router) PATCH

func (r *Router) PATCH(path string, handler http.Handler) *route

func (*Router) POST

func (r *Router) POST(path string, handler http.Handler) *route

func (*Router) PUT

func (r *Router) PUT(path string, handler http.Handler) *route

func (*Router) ServeHTTP

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

method implemented just to fullfill the http.Handler interface, should not be called router must be transformed to a MountedRouter via Mount() method in order to serve http

type Vars

type Vars struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*Vars) Get

func (v *Vars) Get(key string) string

func (*Vars) Has

func (v *Vars) Has(key string) bool

func (*Vars) SetStruct

func (v *Vars) SetStruct(ptrToStruct interface{}, key string)

Jump to

Keyboard shortcuts

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