anyfn

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrType defines the error's type
	ErrType = reflect.TypeOf((*error)(nil)).Elem()
)

参考 https://github.com/uber-go/dig/blob/master/types.go nolint:gochecknoglobals

View Source
var GinContextType = reflect.TypeOf((*gin.Context)(nil)).Elem()
View Source
var HTTPRequestType = reflect.TypeOf((*http.Request)(nil)).Elem()
View Source
var HTTPResponseWriterType = reflect.TypeOf((*http.ResponseWriter)(nil)).Elem()

Functions

func AsError

func AsError(t reflect.Type) bool

AsError tells t whether it implements error type exactly.

func BindSupport

func BindSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func ContextKeyValuesSupport

func ContextKeyValuesSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func ConvertPtr

func ConvertPtr(isPtr bool, v reflect.Value) reflect.Value

func DefaultSupport

func DefaultSupport(v0 interface{}, vs []interface{}, g *gin.Context) (bool, error)

func DirectDealerSupport

func DirectDealerSupport(v interface{}, vs []interface{}, c *gin.Context) (bool, error)

func ErrorSupport

func ErrorSupport(v interface{}, vs []interface{}, c *gin.Context) (bool, error)

func GinContextSupport

func GinContextSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func HTTPRequestSupport

func HTTPRequestSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func HTTPResponseWriterSupport

func HTTPResponseWriterSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func ImplType

func ImplType(src, target reflect.Type) bool

ImplType tells src whether it implements target type.

func IsAdapterError

func IsAdapterError(err error) bool

IsAdapterError tells the err is an AdaptorError or not.

func IsError

func IsError(t reflect.Type) bool

IsError tells t whether it is error type exactly.

func NonPtrTypeOf

func NonPtrTypeOf(v interface{}) reflect.Type

NonPtrTypeOf returns the non-ptr type of v.

func SinglePrimitiveValueSupport

func SinglePrimitiveValueSupport(arg ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

Types

type Adapter

type Adapter struct {
	InSupports  []InSupport
	OutSupports []OutSupport
}

func NewAdapter

func NewAdapter() *Adapter

func (*Adapter) Adapt

func (a *Adapter) Adapt(relativePath string, argV interface{}) adapt.Handler

func (*Adapter) AddInSupport

func (a *Adapter) AddInSupport(support InSupport)

func (*Adapter) AddOutSupport

func (a *Adapter) AddOutSupport(support OutSupport)

func (*Adapter) After

func (a *Adapter) After(after After) OptionFn

func (*Adapter) Attr

func (a *Adapter) Attr(k string, v interface{}) OptionFn

func (*Adapter) AttrMap

func (a *Adapter) AttrMap(attrs map[string]interface{}) OptionFn

func (*Adapter) Before

func (a *Adapter) Before(before Before) OptionFn

func (*Adapter) Default

func (a *Adapter) Default(relativePath string) adapt.Handler

func (*Adapter) F

func (a *Adapter) F(v interface{}, fns ...OptionFn) *anyF

type AdapterError

type AdapterError struct {
	Err     error
	Context string
}

AdapterError defines the error generated in the processing of adaptor.

func (*AdapterError) Error

func (e *AdapterError) Error() string

Error returns the error message.

type After

type After interface {
	// Do will be called Before the adaptee invoking.
	Do(args []interface{}, results []interface{}) error
}

type AfterFn

type AfterFn func(args []interface{}, results []interface{}) error

func (AfterFn) Do

func (b AfterFn) Do(args []interface{}, results []interface{}) error

type ArgIn

type ArgIn struct {
	Index int
	Type  reflect.Type
	Kind  reflect.Kind
	Ptr   bool
}

type Before

type Before interface {
	// Do will be called Before the adaptee invoking.
	Do(args []interface{}) error
}

type BeforeFn

type BeforeFn func(args []interface{}) error

func (BeforeFn) Do

func (b BeforeFn) Do(args []interface{}) error

type DirectDealer

type DirectDealer interface {
	Deal(*gin.Context)
}

DirectDealer is the dealer for a specified type.

type DirectResponse

type DirectResponse struct {
	Code        int
	Error       error
	JSON        interface{}
	String      string
	ContentType string
	Header      map[string]string
}

DirectResponse represents the direct response.

func (DirectResponse) Deal

func (d DirectResponse) Deal(c *gin.Context)

type DlFile

type DlFile struct {
	DiskFile string
	Filename string
	Content  []byte
}

DlFile represents the file to be downloaded.

func (DlFile) Deal

func (d DlFile) Deal(c *gin.Context)

Deal is the processor for a specified type.

type HTTPStatus

type HTTPStatus int

HTTPStatus defines the type of HTTP state.

func (HTTPStatus) Deal

func (h HTTPStatus) Deal(c *gin.Context)

type InSupport

type InSupport interface {
	Support(argIn ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)
}

type InSupportFn

type InSupportFn func(argIn ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

func (InSupportFn) Support

func (f InSupportFn) Support(argIn ArgIn, argsIn []ArgIn, c *gin.Context) (reflect.Value, error)

type Option

type Option struct {
	Before Before
	After  After
	Attrs  map[string]interface{}
}

type OptionFn

type OptionFn func(*Option)

type OutSupport

type OutSupport interface {
	Support(v interface{}, vs []interface{}, c *gin.Context) (bool, error)
}

type OutSupportFn

type OutSupportFn func(v interface{}, vs []interface{}, c *gin.Context) (bool, error)

func (OutSupportFn) Support

func (o OutSupportFn) Support(v interface{}, vs []interface{}, c *gin.Context) (bool, error)

type Values

type Values []reflect.Value

func (Values) Interface

func (v Values) Interface() []interface{}

Jump to

Keyboard shortcuts

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