middleware

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TypeMiddleAll 全部操作都允许
	TypeMiddleAll = int8(0)
	//TypeMiddleEncode 只允许编码,后端返回给前端的响应处理
	TypeMiddleEncode = int8(1)
	//TypeMiddleDecode 只允许解码,前端请求后端的请求参数处理
	TypeMiddleDecode = int8(2)
)

Variables

This section is empty.

Functions

func Request

func Request(data interface{}, i IMiddleware)

Request request handler

func Response

func Response(data interface{}, err error, r ResponseRender, i IMiddleware)

Response response handler

Types

type Aggregate

type Aggregate struct {
	Hitn      string `json:"hitn"`      //name的多个结构体用.表示分级
	Hitv      string `json:"hitv"`      //枚举值
	Mapn      string `json:"mapn"`      //映射字段名,可以与hitname不同,也可以相同
	Mapv      string `json:"mapv"`      //映射字段值
	Delimiter string `json:"delimiter"` //映射字段值的分隔符号
	Order     int64  `json:"order"`     //顺序
	Type      int8   `json:"type"`
}

Aggregate 前端映射结构,对应于前后端交互的字段

func (*Aggregate) Process

func (f *Aggregate) Process(data interface{}, encode bool)

type AggregateArr

type AggregateArr []*Aggregate

AggregateArr arr

func (AggregateArr) Len

func (f AggregateArr) Len() int

Len .

func (AggregateArr) Less

func (f AggregateArr) Less(i, j int) bool

Less .

func (AggregateArr) Swap

func (f AggregateArr) Swap(i, j int)

Swap .

type IMiddleware

type IMiddleware interface {
	Process(data interface{})
}

IMiddleware handler

type MiddleAggregate

type MiddleAggregate struct {
	Cfg    []*Aggregate
	Encode bool
}

MiddleAggregate 处理聚合逻辑

func (*MiddleAggregate) Process

func (m *MiddleAggregate) Process(data interface{})

Process handle multi aggregate logists

type ResponseRender

type ResponseRender func(data interface{}, err error)

ResponseRender .

Jump to

Keyboard shortcuts

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