router

package
v0.0.0-...-bfd235e Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownChannel = errors.New("Unknown channel type")

Functions

func CleanPath

func CleanPath(p string) string

CleanPath is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.

The following rules are applied iteratively until no further processing can be done:

  1. Replace multiple slashes with a single slash.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.

If the result of this process is an empty string, "/" is returned

Types

type Handler

type Handler interface {
	Handle(*UrlContext) error
}

type HandlerFunc

type HandlerFunc func(*UrlContext) error

type PanicHandler

type PanicHandler interface {
	Handle(*UrlContext, interface{})
}

type Param

type Param struct {
	Key, Value string
}

type Params

type Params []Param

func (Params) ByName

func (p Params) ByName(key string) string

type Router

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

func New

func New(l log.Logger, panicHandler PanicHandler, notFound Handler) *Router

func (*Router) GetRoute

func (r *Router) GetRoute(path string) (Handler, Params, bool)

func (*Router) Handle

func (r *Router) Handle(c *UrlContext) error

func (*Router) HasRoute

func (r *Router) HasRoute(path string) bool

func (*Router) Register

func (r *Router) Register(path string, handle Handler)

func (*Router) RegisterFunc

func (r *Router) RegisterFunc(path string, handle HandlerFunc)

type UrlContext

type UrlContext struct {
	Path     string
	Params   Params
	Values   url.Values
	Context  context.Context
	Channel  ssh.Channel
	Requests <-chan *ssh.Request
}

Jump to

Keyboard shortcuts

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