Documentation ¶
Index ¶
- func NotFound(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func StoreParam(ctx context.Context, name string, value string) context.Context
- func URLPart(ctx context.Context, r *http.Request, i int) (context.Context, string, bool)
- func URLParts(ctx context.Context, r *http.Request) (context.Context, []string)
- type Dispatcher
- type Handler
- type HandlerFunc
- type HandlerList
- type Middleware
- type Param
- func (p Param) Float32() (float32, error)
- func (p Param) Float64() (float64, error)
- func (p Param) Int() (int, error)
- func (p Param) Int32() (int32, error)
- func (p Param) Int64() (int64, error)
- func (p Param) String() (string, error)
- func (p Param) UInt() (uint, error)
- func (p Param) UInt32() (uint32, error)
- func (p Param) UInt64() (uint64, error)
- type Platform
- type Route
- type Router
- func (r *Router) AddHandlerBuilder(builder func(interface{}) (Handler, error))
- func (r *Router) Delete(pattern string, handlers ...interface{}) *Router
- func (r *Router) Get(pattern string, handlers ...interface{}) *Router
- func (r *Router) Group(pattern string, group func(*Router))
- func (r *Router) Handle(pattern string, handlers ...interface{}) *Router
- func (r *Router) Head(pattern string, handlers ...interface{}) *Router
- func (r *Router) Host(hosts ...string) *Router
- func (r *Router) NotFound(i interface{})
- func (r *Router) Options(pattern string, handlers ...interface{}) *Router
- func (r *Router) Platform(pattern string, platform Platform)
- func (r *Router) Post(pattern string, handlers ...interface{}) *Router
- func (r *Router) Put(pattern string, handlers ...interface{}) *Router
- func (r *Router) Route(pattern string) *Router
- func (r *Router) Use(middleware ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StoreParam ¶
StoreParam stores a variable in a context
Types ¶
type Dispatcher ¶
type Dispatcher interface { http.Handler Handler Handle(route Route, handlers ...Handler) Middleware(route Route, middleware ...Middleware) NotFoundHandler(route Route, handler Handler) }
Dispatcher dipatches requests to routes
func DefaultDispatcher ¶
func DefaultDispatcher() Dispatcher
DefaultDispatcher implements dispatcher allowing for basic url params
type Handler ¶
Handler is a context aware handler
var NotFoundHandler Handler = HandlerFunc(NotFound)
NotFoundHandler is a not found handler
func Scaffold ¶
func Scaffold(d Dispatcher, platform Platform) Handler
Scaffold creates a router and passes it to a platorm
type HandlerFunc ¶
HandlerFunc wraps a handler letting it implement Handler
func (HandlerFunc) CtxServeHTTP ¶
func (h HandlerFunc) CtxServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request)
CtxServeHTTP implements Handler.CtxServeHTTP
type HandlerList ¶
type HandlerList []Handler
HandlerList is an array of handlers
func (HandlerList) CtxServeHTTP ¶
func (h HandlerList) CtxServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request)
CtxServeHTTP implements Handler.CtxServeHTTP
type Middleware ¶
Middleware is middleware for a router
func MiddlewareList ¶
func MiddlewareList(middlware []Middleware) Middleware
MiddlewareList list creates a single middlware callback from an array
type Param ¶
type Param string
Param is a parameter
type Platform ¶
type Platform interface {
Routes(*Router)
}
Platform is a object that can specify its own routes
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a HTTP router
func (*Router) AddHandlerBuilder ¶
AddHandlerBuilder adds a builder to construct handlers
func (*Router) NotFound ¶
func (r *Router) NotFound(i interface{})
NotFound specifys a not found handler for a route