middlewares

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(ctx context.Context, middleware, middlewareType string) *zerolog.Logger

GetLogger creates a logger with the middleware fields.

func GetSourceExtractor

func GetSourceExtractor(ctx context.Context, sourceMatcher *dynamic.SourceCriterion) (utils.SourceExtractor, error)

GetSourceExtractor returns the SourceExtractor function corresponding to the given sourceMatcher. It defaults to a RemoteAddrStrategy IPStrategy if need be. It returns an error if more than one source criterion is provided.

func NewResponseModifier

func NewResponseModifier(w http.ResponseWriter, r *http.Request, modifier func(*http.Response) error) http.ResponseWriter

NewResponseModifier returns a new ResponseModifier instance. The given modifier can be nil.

Types

type HTTPHandlerSwitcher

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

HTTPHandlerSwitcher allows hot switching of http.ServeMux.

func NewHandlerSwitcher

func NewHandlerSwitcher(newHandler http.Handler) (hs *HTTPHandlerSwitcher)

NewHandlerSwitcher builds a new instance of HTTPHandlerSwitcher.

func (*HTTPHandlerSwitcher) GetHandler

func (h *HTTPHandlerSwitcher) GetHandler() (newHandler http.Handler)

GetHandler returns the current http.ServeMux.

func (*HTTPHandlerSwitcher) ServeHTTP

func (h *HTTPHandlerSwitcher) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*HTTPHandlerSwitcher) UpdateHandler

func (h *HTTPHandlerSwitcher) UpdateHandler(newHandler http.Handler)

UpdateHandler safely updates the current http.ServeMux with a new one.

type ResponseModifier

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

ResponseModifier is a ResponseWriter to modify the response headers before sending them.

func (*ResponseModifier) Flush

func (r *ResponseModifier) Flush()

Flush sends any buffered data to the client.

func (*ResponseModifier) Header

func (r *ResponseModifier) Header() http.Header

func (*ResponseModifier) Hijack

func (r *ResponseModifier) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack hijacks the connection.

func (*ResponseModifier) Write

func (r *ResponseModifier) Write(b []byte) (int, error)

func (*ResponseModifier) WriteHeader

func (r *ResponseModifier) WriteHeader(code int)

WriteHeader is, in the specific case of 1xx status codes, a direct call to the wrapped ResponseWriter, without marking headers as sent, allowing so further calls.

type Stateful

type Stateful interface {
	http.ResponseWriter
	http.Hijacker
	http.Flusher
}

Stateful interface groups all http interfaces that must be implemented by a stateful middleware (ie: recorders).

Directories

Path Synopsis
Package capture is a middleware that captures requests/responses size, and status.
Package capture is a middleware that captures requests/responses size, and status.
Package headers Middleware based on https://github.com/unrolled/secure.
Package headers Middleware based on https://github.com/unrolled/secure.
Package ratelimiter implements a rate limiting and traffic shaping middleware with a set of token buckets.
Package ratelimiter implements a rate limiting and traffic shaping middleware with a set of token buckets.
tcp

Jump to

Keyboard shortcuts

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