middleware

package
v0.0.0-...-96965a9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAfter

func DefaultAfter(res negroni.ResponseWriter, latency time.Duration, msg string)

DefaultAfter -- is the default func assigned to *Middleware.After

func DefaultBefore

func DefaultBefore(req *http.Request, remoteAddr, msg string)

DefaultBefore is the default func assigned to *Middleware.Before

Types

type AfterFunc

type AfterFunc func(negroni.ResponseWriter, time.Duration, string)

AfterFunc is the func type used to modify or replace the *logrus.Entry after calling the next func in the middleware chain

type BeforeFunc

type BeforeFunc func(*http.Request, string, string)

BeforeFunc is the func type used to modify or replace the *logrus.Entry prior to calling the next func in the middleware chain

type CorsMiddleware

type CorsMiddleware struct {
}

CorsMiddleware is a middleware handler that support CORS response header

func NewCorsMiddleware

func NewCorsMiddleware() *CorsMiddleware

NewCorsMiddleware returns a new *Middleware which writes to a given logger.

func (*CorsMiddleware) ServeHTTP

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

ServeHTTP --

type HttpLogMiddleware

type HttpLogMiddleware struct {
	Before BeforeFunc
	After  AfterFunc
	// contains filtered or unexported fields
}

HttpLogMiddleware is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewHttpLogMiddleware

func NewHttpLogMiddleware() *HttpLogMiddleware

NewHttpLogMiddleware returns a new *Middleware which writes to a given logger.

func (*HttpLogMiddleware) ExcludeURL

func (m *HttpLogMiddleware) ExcludeURL(u string) error

ExcludeURL -- adds a new URL u to be ignored during logging. The URL u is parsed, hence the returned error

func (*HttpLogMiddleware) ExcludedURLs

func (m *HttpLogMiddleware) ExcludedURLs() []string

ExcludedURLs -- returns the list of excluded URLs for this middleware

func (*HttpLogMiddleware) ServeHTTP

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

ServeHTTP --

type PreFlightMiddleware

type PreFlightMiddleware struct {
}

PreFlightMiddleware is a middleware handler that support pre-flight OPTIONS request

func NewPreFlightMiddleware

func NewPreFlightMiddleware() *PreFlightMiddleware

NewPreFlightMiddleware returns a new *Middleware which writes to a given logger.

func (*PreFlightMiddleware) ServeHTTP

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

ServeHTTP --

type RecoveryMiddleware

type RecoveryMiddleware struct {
	PrintStack bool
	StackAll   bool
	StackSize  int
	Formatter  negroni.PanicFormatter
}

RecoveryMiddleware is a middleware that recovers from any panics and writes a 500 if there was one.

func NewRecoveryMiddleware

func NewRecoveryMiddleware(printStack bool) *RecoveryMiddleware

func (*RecoveryMiddleware) ServeHTTP

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

ServeHTTP --

type TimeoutMiddleware

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

TimeoutMiddleware is a middleware handler that support CORS response header

func NewTimeoutMiddleware

func NewTimeoutMiddleware(timeout time.Duration) *TimeoutMiddleware

NewTimeoutMiddleware returns a new *Middleware which writes to a given logger.

func (*TimeoutMiddleware) ServeHTTP

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

ServeHTTP --

Jump to

Keyboard shortcuts

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