middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequestFilter

func AddRequestFilter(f RequestFilter)

添加前置过滤器 order=0不强调顺序

func AddResponseFilter

func AddResponseFilter(f ResponseFilter)

func ForEachRequestFilter

func ForEachRequestFilter(w http.ResponseWriter, r *http.Request, logger *zap.Logger) bool

遍历执行请求拦截器

func ForEachResponseFilter

func ForEachResponseFilter(w http.ResponseWriter, r *http.Request, logger *zap.Logger, data interface{}, ex *exception.Exception) (interface{}, *exception.Exception)

遍历执行响应拦截器

Types

type Binder

type Binder struct{}

func (Binder) Handler

func (b Binder) Handler(w http.ResponseWriter, r *http.Request, logger *zap.Logger) bool

type Filter

type Filter struct {
	Order int
}

type JSONRender

type JSONRender struct {
}

func (JSONRender) Handler

func (response JSONRender) Handler(w http.ResponseWriter, r *http.Request, logger *zap.Logger, data interface{}, ex *exception.Exception) (interface{}, *exception.Exception)

type RequestFilter

type RequestFilter interface {
	Handler(w http.ResponseWriter, r *http.Request, logger *zap.Logger) bool
}

前置过滤器 返回false不在继续执行

type ResponseFilter

type ResponseFilter interface {
	Handler(w http.ResponseWriter, r *http.Request, logger *zap.Logger, data interface{}, ex *exception.Exception) (interface{}, *exception.Exception)
}

后置过滤器

type Validator

type Validator struct{}

func (Validator) Handler

func (b Validator) Handler(w http.ResponseWriter, r *http.Request, logger *zap.Logger) bool

Jump to

Keyboard shortcuts

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