middleware

package
v0.0.0-...-d3f65ed Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint func(context.Context, interface{}) (interface{}, error)

Endpoint func(ctx context.Context,request interface{}) (response interface{},err error)

type HandlerFunc

type HandlerFunc func(error) error

HandlerFunc 错误处理

type MiddleWare

type MiddleWare func(Endpoint) Endpoint

MiddleWare 方便链式操作

func Chain

func Chain(outer MiddleWare, others ...MiddleWare) MiddleWare

Chain 连接成链路 outer 最外层的

Example
e := Chain(
	annotate("first"),
	annotate("second"),
	annotate("third"),
)(myEndpoint)

if _, err := e(ctx, req); err != nil {
	panic(err)
}
Output:

Jump to

Keyboard shortcuts

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