midware

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interceptor

type Interceptor interface {

	// higher prior
	Priority() int
	Intercept(ctx *common.RequestCtx) (InterceptorAction, interface{})
}

type InterceptorAction

type InterceptorAction int
const (

	// call next interceptor Routine
	// returned value must be nil
	Continue InterceptorAction

	// block the request,
	// returned value can be assigned by the second parameter
	Block

	// skip other interceptors, enter normal handler, not recommended
	// returned value must be nil
	Skip
)

type InterceptorChain

type InterceptorChain struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewInterceptorChain

func NewInterceptorChain() *InterceptorChain

func (*InterceptorChain) AddInterceptor

func (r *InterceptorChain) AddInterceptor(interceptor Interceptor)

func (*InterceptorChain) CallInterceptors

func (r *InterceptorChain) CallInterceptors(ctx *common.RequestCtx) (bool, interface{})

interceptor chain returns a bool tell if the request should be blocked or resumed second parameter will be treat as the response body

Jump to

Keyboard shortcuts

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