codec

package
v0.2.14 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterFetcher

type AfterFetcher interface {

	//AfterFetch one of the lifecycle hooks, returns bool if response was closed (i.e. response.WriteHeader())
	//or just an error if it is needed to stop the routers flow.
	//view is type of *[]T or *[]*T
	AfterFetch(data interface{}, response http.ResponseWriter, request *http.Request) (responseClosed bool, err error)
}

AfterFetcher represents Lifecycle hook with is called after view was read from Database. It is important to specify View type for assertion type purposes.

type BeforeFetcher

type BeforeFetcher interface {
	//BeforeFetch one of the lifecycle hooks, returns bool if response was closed (i.e. response.WriteHeader())
	//or just an error if it is needed to stop the routers flow.
	BeforeFetch(response http.ResponseWriter, request *http.Request) (responseClosed bool, err error)
}

BeforeFetcher represents Lifecycle hook which is called before view was read from the Database.

type Codec

type Codec interface {
	LifecycleVisitor
	ResultType() reflect.Type
}

func NewCodec added in v0.2.2

func NewCodec(name string, valuer Valuer, resultType reflect.Type) Codec

type LifecycleVisitor

type LifecycleVisitor interface {
	Valuer() Valuer
	Name() string
}

LifecycleVisitor visitor can implement BeforeFetcher and/or AfterFetcher

func NewVisitor added in v0.2.2

func NewVisitor(name string, visitor Valuer) LifecycleVisitor

type Valuer added in v0.2.2

type Valuer interface {
	Value(ctx context.Context, raw interface{}, options ...interface{}) (interface{}, error)
}

func NewValuer added in v0.2.2

func NewValuer(aFunc func(ctx context.Context, raw interface{}, options ...interface{}) (interface{}, error)) Valuer

type Visitor

type Visitor struct {
	shared.Reference
	// contains filtered or unexported fields
}

func (*Visitor) Inherit

func (v *Visitor) Inherit(visitor LifecycleVisitor)

func (*Visitor) Name

func (v *Visitor) Name() string

func (*Visitor) Valuer added in v0.2.2

func (v *Visitor) Valuer() Valuer

func (*Visitor) Visitor

func (v *Visitor) Visitor() interface{}

type Visitors

type Visitors map[string]LifecycleVisitor

func New

func New(visitors ...LifecycleVisitor) Visitors

func (Visitors) Lookup

func (v Visitors) Lookup(name string) (LifecycleVisitor, error)

func (Visitors) Register

func (v Visitors) Register(visitor LifecycleVisitor)

Jump to

Keyboard shortcuts

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