aop

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(ctx context.Context)

After 函式執行後

func Before

func Before(ctx context.Context, fn interface{}, args ...interface{}) (context.Context, error)

Before 函式執行前

func IndirectType

func IndirectType(reflectType reflect.Type) reflect.Type

IndirectType 获取真正型别

func RegisterCustomValueHandle

func RegisterCustomValueHandle(t reflect.Type, valuer CustomValueHandle)

RegisterCustomValueHandle 注册自定义Valuer展开函数

func RegisterNamesIn

func RegisterNamesIn(fn interface{}, names ...string)

RegisterNamesIn 手工注册函数的参数名称列表

func Use

func Use(middlewares ...Handler)

Use 註冊中間件

Types

type Config

type Config struct {
	sync.RWMutex
	//Pkg 包名替換規則
	Pkg map[string]string
	//NamesIn 函数参数名称
	NamesIn map[string][]string
}

Config AOP設定

func (*Config) Replace

func (cfg *Config) Replace(name string) string

Replace 替換包名

type Context

type Context struct {
	FuncMetadata *FuncMetadata
	FuncInArgs   FuncInArgs

	Values map[interface{}]interface{}
	// contains filtered or unexported fields
}

Context aop上下文

func NewContext

func NewContext(ctx context.Context) *Context

NewContext 創建AOP上下文

func (*Context) Deadline

func (ctx *Context) Deadline() (deadline time.Time, ok bool)

Deadline see context.Context.Deadline

func (*Context) Done

func (ctx *Context) Done() <-chan struct{}

Done see context.Context.Done

func (*Context) Err

func (ctx *Context) Err() error

Err see context.Context.Err

func (*Context) Value

func (ctx *Context) Value(key interface{}) interface{}

Value see context.Context.Value

type CustomValueHandle

type CustomValueHandle func(obj interface{}) map[string]interface{}

CustomValueHandle 自定义Valuer展开函数

type FuncInArgs

type FuncInArgs []interface{}

FuncInArgs 函数参数修正集合

type FuncMetadata

type FuncMetadata struct {
	//Type 型別信息
	Type reflect.Type
	//Name 完整名稱包含包地址
	Name string
	//NumIn 變數數量
	NumIn int
	//NamesIn 變數名稱
	NamesIn []string
	//FixedNamesIn -/+ 修正后的参数列表
	FixedNamesIn []string
}

FuncMetadata func反射後得到的元數據

type Handler

type Handler interface {
	//Before 執行前
	Before(ctx *Context) error
	//After 執行後
	After(ctx *Context)
}

Handler 請求攔截器

type Valuer

type Valuer interface {
	Value() map[string]interface{}
}

Valuer 将各种型别的变数转化成健值对

Directories

Path Synopsis
handler
authz
Package authz authorization
Package authz authorization
tools
go-aop command

Jump to

Keyboard shortcuts

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