middleware

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNativeContext

func GetNativeContext(ctx *fasthttp.RequestCtx) context.Context

GetNativeContext retrieve a standard library context from FastHTTP request context.

func WithNativeContext

func WithNativeContext(ctx *fasthttp.RequestCtx, nativeCtx context.Context)

WithNativeContext stores a standard library context into FastHTTP request context.

Types

type ConnManager

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

ConnManager keeps track of active TCP connections and their corresponding contexts.

When a connection is closed by the client it cancel its context.

func NewConnManager

func NewConnManager(log restql.Logger, enabled bool, watchInterval time.Duration) *ConnManager

NewConnManager creates a connection manager

func (*ConnManager) ContextForConnection

func (cm *ConnManager) ContextForConnection(conn net.Conn) context.Context

ContextForConnection get the connections context, if it exists. Otherwise it create a context and start the connection watcher.

type Decorator

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

Decorator is a type responsible for wrapping handlers with default and config enabled middlewares.

func NewDecorator

func NewDecorator(log restql.Logger, cfg *conf.Config, pm plugins.Lifecycle) *Decorator

NewDecorator creates a middleware Decorator

func (*Decorator) Apply

Apply takes a base handler and fetches all middlewares enabled in configuration decorating the argument with each one.

type Middleware

type Middleware interface {
	Apply(h fasthttp.RequestHandler) fasthttp.RequestHandler
}

Middleware defines a generic handler wrapper capable of controlling request flow.

Jump to

Keyboard shortcuts

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