kate

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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

func StdHandler(ctx context.Context, h ContextHandler, maxBodyBytes int64) http.Handler

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

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 DELETE

DELETE only allow DELETE method

func GET

GET only allow GET method

HEAD only allow HEAD method

func MethodOnly

func MethodOnly(method string, h ContextHandler) ContextHandler

MethodOnly is a middleware to restrict http method for standard http router

func OPTIONS

func OPTIONS(h ContextHandler) ContextHandler

OPTIONS only allow OPTIONS method

func PATCH

PATCH only allow PATCH method

func POST

POST only allow POST method

func PUT

PUT only allow PUT method

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

type Router struct {
	*http.ServeMux
	// contains filtered or unexported fields
}

Router defines the standard http outer

func NewRouter

func NewRouter(ctx context.Context, logger *zap.Logger) *Router

NewRouter create a http router

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

func (r *Router) HandleFunc(pattern string, h func(context.Context, ResponseWriter, *Request))

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

func (r *Router) SetMaxBodyBytes(n int64)

SetMaxBodyBytes set the body size limit

func (*Router) StdHandle added in v1.2.0

func (r *Router) StdHandle(pattern string, h http.Handler)

StdHandle register a standard http handler for the specified path

Directories

Path Synopsis
log
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
csv

Jump to

Keyboard shortcuts

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