hook

package
v0.9.24 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cargo

type Cargo struct {
	Payload interface{}
}

Cargo is payload between hookpoints

type Data

type Data struct {
	// Ms is the slice of IModels
	Ms []mdl.IModel
	// DB is the DB handle
	DB *gorm.DB
	// Cargo between Before and After hookpoints (not used in AfterRead since there is before read hookpoint.)
	Cargo *Cargo
	// Role of this user in relation to this data, only available during read
	Roles []userrole.UserRole
}

Data is the data send to batch model hookpoints

type EndPoint

type EndPoint struct {
	// TypeString
	TypeString string

	URL         string
	Op          rest.Op
	Cardinality rest.Cardinality

	// URL parameters
	URLParams map[urlparam.Param]interface{}

	// Who is operating this CRUPD right now
	Who mdlutil.UserIDFetchable
}

Endpoint information

type IAfter

type IAfter interface {
	After(data *Data, info *EndPoint) *webrender.RetError
}

IAfter supports method to be called after data is after all CRUPD operations

type IAfterTransact

type IAfterTransact interface {
	AfterTransact(data *Data, info *EndPoint)
}

IAfterTransact is the method to be called after data is after the entire database transaction is done. No error is returned because database transaction is already committed.

type IBefore

type IBefore interface {
	Before(data *Data, info *EndPoint) *webrender.RetError
}

IBefore supports method to be called before data is fetched for all CRUPD operations

type IBeforeApply

type IBeforeApply interface {
	BeforeApply(data *Data, info *EndPoint) *webrender.RetError
}

IBeforeApply before patching operation occurred. Only called for Patch. This comes before patch is applied. Before "Before"

type IHook

type IHook interface {
	// Init data for this REST operation
	Init(data *InitData, args ...interface{})
}

type IRender

type IRender interface {
	Render(c *gin.Context, data *Data, ep *EndPoint, total *int) bool
}

IRender is for formatting IModel with a custom function basically do your own custom output If return false, use the default JSON output

type InitData

type InitData struct {
	// Role of this user in relation to this data, only available during read
	Roles []userrole.UserRole

	// Info is endpoint information
	Ep *EndPoint
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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