reqmw

package
v0.0.0-...-9d84085 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoNothingRequestMiddleware

type DoNothingRequestMiddleware struct{}

DoNothingRequestMiddleware an NO-OP implemenation of the RequestMiddleware interface

func NewDoNothingRequestMiddleware

func NewDoNothingRequestMiddleware() *DoNothingRequestMiddleware

NewDoNothingRequestMiddleware returns an DoNothingRequestMiddleware

func (*DoNothingRequestMiddleware) Do

Do does nothing to the given request

func (*DoNothingRequestMiddleware) Wrap

Wrap adds functionality to a middleware

type MiddlewareNodeFn

type MiddlewareNodeFn func(
	rw http.ResponseWriter,
	req *http.Request,
	next http.HandlerFunc,
)

MiddlewareNodeFn represents the functionality of a single middleware in the chain. Each of these functions is responsible for invoking the next() middleware in the chain and handling the error.

type RequestMiddleware

type RequestMiddleware interface {
	Do(http.ResponseWriter, *http.Request)
	Wrap(http.HandlerFunc) RequestMiddleware
}

RequestMiddleware represents the request-processing middleware functionality of a multiple-host proxy

type RequestMiddlewareChain

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

RequestMiddlewareChain represents a linked-list-like data structure where each node is a middleware to be executed

func NewRequestMiddlewareChain

func NewRequestMiddlewareChain(layers ...MiddlewareNodeFn) *RequestMiddlewareChain

NewRequestMiddlewareChain returns a new RequestMiddlewareChain initialized with the given list of MiddlewareNodeFn. They will be executed in the order in which they are given.

func (*RequestMiddlewareChain) Do

Do executes the current MiddlewareNodeFn, with the next MiddlewareNodeFn as the next argument

func (*RequestMiddlewareChain) Wrap

Wrap adds a function to the end of a RequestMiddlewareChain

Jump to

Keyboard shortcuts

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