middleware

package
v0.0.0-...-9967220 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReqID

func GetReqID(ctx context.Context) string

Types

type CloseNotify

type CloseNotify struct {
}

func NewCloseNotify

func NewCloseNotify() *CloseNotify

NewCloseNotify returns a new CloseNotify instance

func (*CloseNotify) ServeHTTP

func (c *CloseNotify) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Logger

type Logger struct {
	Level string
	File  *os.File
}

func NewLogger

func NewLogger(level string, name string) *Logger

NewLogger returns a new Logger instance

func (*Logger) ServeHTTP

func (m *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type ParseForm

type ParseForm struct {
}

func NewParseForm

func NewParseForm() *ParseForm

NewParseForm returns a new Recovery instance

func (*ParseForm) ServeHTTP

func (m *ParseForm) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

ParseForm is a doggy middleware that call ParseForm for every http request.

type Prometheus

type Prometheus struct {
}

func NewPrometheus

func NewPrometheus() *Prometheus

NewPrometheus returns a new Prometheus instance

func (*Prometheus) ServeHTTP

func (p *Prometheus) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type RateLimit

type RateLimit struct {
	Rate     float64
	Capacity int64
}

func NewRateLimit

func NewRateLimit(rate float64, capacity int64) *RateLimit

NewRateLimit returns a new RateLimit instance

func (*RateLimit) ServerHTTP

func (m *RateLimit) ServerHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

RateLimit is an Middleware that acts as a request throttler based on a token-bucket algorithm. Requests that would exceed the maximum request rate are delayed via the parameterized sleep function.

type RealIP

type RealIP struct {
}

func NewRealIP

func NewRealIP() *RealIP

NewRealIP returns a new RealIP instance

func (*RealIP) ServeHTTP

func (m *RealIP) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type Recovery

type Recovery struct {
}

func NewRecovery

func NewRecovery() *Recovery

NewRecovery returns a new Recovery instance

func (*Recovery) ServeHTTP

func (m *Recovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Recovery is a doggy middleware that recovers from any panics and writes a 500.

type Timeout

type Timeout struct {
	Timeout time.Duration
}

func NewTimeout

func NewTimeout(timeout time.Duration) *Timeout

NewTimeout returns a new Timeout instance

func (*Timeout) ServeHTTP

func (m *Timeout) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type TraceID

type TraceID struct {
}

func NewTraceID

func NewTraceID() *TraceID

NewTraceID returns a new TraceID instance

func (*TraceID) ServeHTTP

func (m *TraceID) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

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