middleware

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MatchedRoutePathKey zinContextKey = iota

Variables

This section is empty.

Functions

func AddRouteToContext

func AddRouteToContext(route string) middleware

func CacheControl

func CacheControl(age int) func(h httprouter.Handle) httprouter.Handle

func Compressor

func Compressor(h httprouter.Handle) httprouter.Handle

Compressor compress the response body if the header of request contained `Accept-Encoding`

func GetRouteFromContext

func GetRouteFromContext(ctx context.Context) (string, bool)

func HMACSHA1Signer

func HMACSHA1Signer(hmacHeaderKey, nounceHeaderKey string, secret []byte) middleware

HMACSHA1Signer returns a middleware wrapper to add hmac signing string in response header

func Logger

func Logger(entry LogEntry) func(httprouter.Handle) httprouter.Handle

func Recoverer

func Recoverer(entry LogEntry) func(httprouter.Handle) httprouter.Handle

Types

type DeferWriter

type DeferWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewDeferWriter

func NewDeferWriter(w http.ResponseWriter) *DeferWriter

func (*DeferWriter) Bytes

func (w *DeferWriter) Bytes() []byte

func (*DeferWriter) Write

func (w *DeferWriter) Write(b []byte) (int, error)

func (*DeferWriter) WriteAll

func (w *DeferWriter) WriteAll()

type LogEntry

type LogEntry interface {
	WithField(string, interface{}) LogEntry
	Infof(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
}

type LoggerHandler

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

func LoggerH

func LoggerH(h http.Handler, entry LogEntry) LoggerHandler

func (LoggerHandler) ServeHTTP

func (lh LoggerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProxyWriter

type ProxyWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewProxyWriter

func NewProxyWriter(w http.ResponseWriter) *ProxyWriter

func (*ProxyWriter) Hijack

func (w *ProxyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*ProxyWriter) Size

func (w *ProxyWriter) Size() int

func (*ProxyWriter) Status

func (w *ProxyWriter) Status() int

func (*ProxyWriter) Write

func (w *ProxyWriter) Write(b []byte) (int, error)

func (*ProxyWriter) WriteHeader

func (w *ProxyWriter) WriteHeader(s int)

type RecovererHandler

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

func RecovererH

func RecovererH(h http.Handler, entry LogEntry) RecovererHandler

func (*RecovererHandler) ServeHTTP

func (rh *RecovererHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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