mux

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 14 Imported by: 3

README

mux

Documentation

Index

Constants

View Source
const (
	HeaderOrigin                        = "Origin"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
)
View Source
const (
	HeaderAccessControlRequestMethod  = "Access-Control-Request-Method"
	HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers"
)
View Source
const (
	HeaderAcceptEncoding  = "Accept-Encoding"
	HeaderContentType     = "Content-Type"
	HeaderContentEncoding = "Content-Encoding"
	HeaderVary            = "Vary"
)
View Source
const (
	HeaderEtag        = "Etag"
	HeaderLongPoll    = "Long-Poll"
	HeaderIfNoneMatch = "If-None-Match"
)
View Source
const (
	ContentEncodingGZIP = "gzip"
)

Variables

This section is empty.

Functions

func ByKind

func ByKind(ks ...Kind) func(*Route) bool

func ByPath

func ByPath(pcs ...string) func(*Route) bool

func DumpRequest

func DumpRequest(next http.Handler) http.Handler

func GZIP

func GZIP(h http.Handler) http.Handler

func LogRequests

func LogRequests(h http.Handler) http.Handler

func LongPolling

func LongPolling() (middleware Decorator, signal SignalFunc)

func NoCache

func NoCache(h http.Handler) http.Handler

IE-Cache-Buster

func SetAllCORSHeaders

func SetAllCORSHeaders(w http.ResponseWriter, r *http.Request, ac AccessControl)

func Tree

func Tree(n *Route) string

Types

type AccessControl

type AccessControl struct {
	AllowOrigin      string
	ExposeHeaders    []string
	MaxAge           uint64
	AllowCredentials bool
	AllowMethods     []string
	AllowHeaders     []string
}
var (
	AccessControlDefaults  AccessControl
	AccessControlPreflight AccessControl
)

type Chain

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

func NewChain

func NewChain(decorators ...Decorator) Chain

func (Chain) Append

func (c Chain) Append(decorators ...Decorator) Chain

func (Chain) Then

func (c Chain) Then(h http.Handler) http.Handler

func (Chain) ThenFunc

func (c Chain) ThenFunc(f http.HandlerFunc) http.Handler

type Decorator

type Decorator func(http.Handler) http.Handler

func CORS

func CORS(ac AccessControl) Decorator

type Kind

type Kind uint8
const (
	KindStatic Kind = iota
	KindParameter
	KindCatchAll
)

func ClassifyKind

func ClassifyKind(path string) Kind

func (Kind) String

func (k Kind) String() string

type Manager

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

func NewManager

func NewManager(options ...func(*Manager) error) (*Manager, error)

func (*Manager) Await

func (m *Manager) Await(key string) Signal

func (*Manager) SetOption

func (m *Manager) SetOption(options ...func(*Manager) error) error

func (*Manager) Signal

func (m *Manager) Signal(prefix string)

type Route

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

func NewRoute

func NewRoute(path string) *Route

func (*Route) Append

func (r *Route) Append(child *Route) error

func (*Route) Children

func (r *Route) Children() Routes

func (*Route) DELETE

func (r *Route) DELETE(h http.Handler)

func (*Route) FirstChild

func (r *Route) FirstChild() *Route

func (*Route) FullPath

func (r *Route) FullPath() string

func (*Route) GET

func (r *Route) GET(h http.Handler)

func (*Route) HEAD

func (r *Route) HEAD(h http.Handler)

func (*Route) Handler

func (r *Route) Handler(m string) (http.Handler, bool)

func (*Route) IsFirstChild

func (r *Route) IsFirstChild() bool

func (*Route) IsLastChild

func (r *Route) IsLastChild() bool

func (*Route) IsLeaf

func (r *Route) IsLeaf() bool

func (*Route) IsRoot

func (r *Route) IsRoot() bool

func (*Route) Kind

func (r *Route) Kind() Kind

func (*Route) LastChild

func (r *Route) LastChild() *Route

func (*Route) Level

func (r *Route) Level() int

func (*Route) Match

func (r *Route) Match(path string) (*Route, map[string]string)

func (*Route) Methods

func (r *Route) Methods() []string

func (*Route) OPTIONS

func (r *Route) OPTIONS(h http.Handler)

func (*Route) PATCH

func (r *Route) PATCH(h http.Handler)

func (*Route) POST

func (r *Route) POST(h http.Handler)

func (*Route) PUT

func (r *Route) PUT(h http.Handler)

func (*Route) Parent

func (r *Route) Parent() *Route

func (*Route) Path

func (r *Route) Path() string

func (*Route) Route

func (r *Route) Route(path string) *Route

func (*Route) Set

func (r *Route) Set(nr *Route) error

func (*Route) SetHandler

func (r *Route) SetHandler(m string, h http.Handler)

func (*Route) Siblings

func (r *Route) Siblings() Routes

func (*Route) String

func (r *Route) String() string

type Router

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

func New

func New() *Router

func (*Router) Route

func (r *Router) Route(path string) *Route

func (*Router) ServeHTTP

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

func (*Router) String

func (r *Router) String() string

type Routes

type Routes []*Route

func (Routes) Filter

func (rs Routes) Filter(f func(r *Route) bool) Routes

func (Routes) FindOne

func (rs Routes) FindOne(f func(r *Route) bool) *Route

func (Routes) Len

func (rs Routes) Len() int

func (Routes) Less

func (rs Routes) Less(i, j int) bool

func (Routes) Swap

func (rs Routes) Swap(i, j int)

type Signal

type Signal chan struct{}

type SignalFunc

type SignalFunc func(key string)

type Timing

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

func NewTiming

func NewTiming() *Timing

func (*Timing) Mark

func (ts *Timing) Mark(key string)

func (*Timing) WriteTo

func (ts *Timing) WriteTo(header http.Header)

Jump to

Keyboard shortcuts

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