anyfn

package
v0.0.0-...-9d95335 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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 IndirectTypeOf

func IndirectTypeOf(v interface{}) reflect.Type

IndirectTypeOf returns the non-ptr type of v.

func IsAdapterError

func IsAdapterError(err error) bool

IsAdapterError tells if err is an AdaptorError or not.

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) 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) adapt.Parent

func (*Adapter) PrependInSupport

func (a *Adapter) PrependInSupport(support InSupport)

func (*Adapter) PrependOutSupport

func (a *Adapter) PrependOutSupport(support OutSupport)

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 {
	InSupport(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) InSupport

func (f InSupportFn) InSupport(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 {
	OutSupport(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) OutSupport

func (o OutSupportFn) OutSupport(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