Documentation ¶
Index ¶
- func Handle(ctx context.Context, h ContextHandler, maxBodyBytes int64) httprouter.Handle
- func StdHandler(ctx context.Context, h ContextHandler, maxBodyBytes int64) http.Handler
- type Chain
- type ContextHandler
- func DELETE(h ContextHandler) ContextHandler
- func GET(h ContextHandler) ContextHandler
- func HEAD(h ContextHandler) ContextHandler
- func MethodOnly(method string, h ContextHandler) ContextHandler
- func OPTIONS(h ContextHandler) ContextHandler
- func PATCH(h ContextHandler) ContextHandler
- func POST(h ContextHandler) ContextHandler
- func PUT(h ContextHandler) ContextHandler
- type ContextHandlerFunc
- type Middleware
- type RESTRouter
- func (r *RESTRouter) DELETE(pattern string, h ContextHandler)
- func (r *RESTRouter) GET(pattern string, h ContextHandler)
- func (r *RESTRouter) HEAD(pattern string, h ContextHandler)
- func (r *RESTRouter) Handle(method, pattern string, h ContextHandler)
- func (r *RESTRouter) HandleFunc(method, pattern string, h func(context.Context, ResponseWriter, *Request))
- func (r *RESTRouter) OPTIONS(pattern string, h ContextHandler)
- func (r *RESTRouter) PATCH(pattern string, h ContextHandler)
- func (r *RESTRouter) POST(pattern string, h ContextHandler)
- func (r *RESTRouter) PUT(pattern string, h ContextHandler)
- func (r *RESTRouter) SetMaxBodyBytes(n int64)
- type Request
- type ResponseWriter
- type Router
- func (r *Router) DELETE(pattern string, h ContextHandler)
- func (r *Router) GET(pattern string, h ContextHandler)
- func (r *Router) HEAD(pattern string, h ContextHandler)
- func (r *Router) Handle(pattern string, h ContextHandler)
- func (r *Router) HandleFunc(pattern string, h func(context.Context, ResponseWriter, *Request))
- func (r *Router) OPTIONS(pattern string, h ContextHandler)
- func (r *Router) PATCH(pattern string, h ContextHandler)
- func (r *Router) POST(pattern string, h ContextHandler)
- func (r *Router) PUT(pattern string, h ContextHandler)
- func (r *Router) SetMaxBodyBytes(n int64)
- func (r *Router) StdHandle(pattern string, h http.Handler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handle ¶
func Handle(ctx context.Context, h ContextHandler, maxBodyBytes int64) httprouter.Handle
Handle adapte the ContextHandler to httprouter.Handle func
func StdHandler ¶
StdHandler adapte ContextHandler to http.Handler interface
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is the middleware chain
func NewChain ¶
func NewChain(middlewares ...Middleware) Chain
NewChain create a new middleware chain
func (Chain) Append ¶
func (c Chain) Append(middlewares ...Middleware) Chain
Append return a new middleware chain with new middleware appended
func (Chain) Then ¶
func (c Chain) Then(h ContextHandler) ContextHandler
Then return a handler wrapped by the middleware chain
func (Chain) ThenFunc ¶
func (c Chain) ThenFunc(h func(context.Context, ResponseWriter, *Request)) ContextHandler
ThenFunc return a handler wrapped by the middleware chain
type ContextHandler ¶
type ContextHandler interface {
ServeHTTP(context.Context, ResponseWriter, *Request)
}
ContextHandler defines the handler interface
func MethodOnly ¶
func MethodOnly(method string, h ContextHandler) ContextHandler
MethodOnly is a middleware to restrict http method for standard http router
type ContextHandlerFunc ¶
type ContextHandlerFunc func(context.Context, ResponseWriter, *Request)
ContextHandlerFunc defines the handler func adapter
func (ContextHandlerFunc) ServeHTTP ¶
func (h ContextHandlerFunc) ServeHTTP(ctx context.Context, w ResponseWriter, r *Request)
ServeHTTP implements the ContextHandler interface
type Middleware ¶
type Middleware func(ContextHandler) ContextHandler
Middleware defines the middleware func
type RESTRouter ¶
type RESTRouter struct { *httprouter.Router // contains filtered or unexported fields }
RESTRouter define the REST router
func NewRESTRouter ¶
func NewRESTRouter(ctx context.Context, logger *zap.Logger) *RESTRouter
NewRESTRouter create a REST router
func (*RESTRouter) DELETE ¶
func (r *RESTRouter) DELETE(pattern string, h ContextHandler)
DELETE register a handler for DELETE request
func (*RESTRouter) GET ¶
func (r *RESTRouter) GET(pattern string, h ContextHandler)
GET register a handler for GET request
func (*RESTRouter) HEAD ¶
func (r *RESTRouter) HEAD(pattern string, h ContextHandler)
HEAD register a handler for HEAD request
func (*RESTRouter) Handle ¶
func (r *RESTRouter) Handle(method, pattern string, h ContextHandler)
Handle register a http handler for the specified method and path
func (*RESTRouter) HandleFunc ¶
func (r *RESTRouter) HandleFunc(method, pattern string, h func(context.Context, ResponseWriter, *Request))
HandleFunc register a http handler for the specified method and path
func (*RESTRouter) OPTIONS ¶
func (r *RESTRouter) OPTIONS(pattern string, h ContextHandler)
OPTIONS register a handler for OPTIONS request
func (*RESTRouter) PATCH ¶
func (r *RESTRouter) PATCH(pattern string, h ContextHandler)
PATCH register a handler for PATCH request
func (*RESTRouter) POST ¶
func (r *RESTRouter) POST(pattern string, h ContextHandler)
POST register a handler for POST request
func (*RESTRouter) PUT ¶
func (r *RESTRouter) PUT(pattern string, h ContextHandler)
PUT register a handler for PUT request
func (*RESTRouter) SetMaxBodyBytes ¶
func (r *RESTRouter) SetMaxBodyBytes(n int64)
SetMaxBodyBytes set the body size limit
type Request ¶
type Request struct { *http.Request RestVars httprouter.Params RawBody []byte }
Request defines the http request
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter StatusCode() int RawBody() []byte }
ResponseWriter defines the response writer
type Router ¶
Router defines the standard http outer
func (*Router) DELETE ¶
func (r *Router) DELETE(pattern string, h ContextHandler)
DELETE register a handler for DELETE request
func (*Router) GET ¶
func (r *Router) GET(pattern string, h ContextHandler)
GET register a handler for GET request
func (*Router) HEAD ¶
func (r *Router) HEAD(pattern string, h ContextHandler)
HEAD register a handler for HEAD request
func (*Router) Handle ¶
func (r *Router) Handle(pattern string, h ContextHandler)
Handle register a http handler for the specified path
func (*Router) HandleFunc ¶
HandleFunc register a http handler for the specified path
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(pattern string, h ContextHandler)
OPTIONS register a handler for OPTIONS request
func (*Router) PATCH ¶
func (r *Router) PATCH(pattern string, h ContextHandler)
PATCH register a handler for PATCH request
func (*Router) POST ¶
func (r *Router) POST(pattern string, h ContextHandler)
POST register a handler for POST request
func (*Router) PUT ¶
func (r *Router) PUT(pattern string, h ContextHandler)
PUT register a handler for PUT request
func (*Router) SetMaxBodyBytes ¶
SetMaxBodyBytes set the body size limit
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package redsync provides a Redis-based distributed mutual exclusion lock implementation as described in the post http://redis.io/topics/distlock.
|
Package redsync provides a Redis-based distributed mutual exclusion lock implementation as described in the post http://redis.io/topics/distlock. |
skel
|
|