Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APICardinality ¶
type APICardinality int
const ( APICardinalityOne APICardinality = 1 APICardinalityMany APICardinality = 2 )
type Data ¶
type Data struct { // Ms is the slice of IModels Ms []models.IModel // DB is the DB handle DB *gorm.DB // Who is operating this CRUPD right now Who UserIDFetchable // TypeString TypeString string // 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 []models.UserRole // URL parameters URLParams map[urlparam.Param]interface{} }
Data is the data send to batch model hookpoints
type EndPointInfo ¶
type EndPointInfo struct { Op RESTOp Cardinality APICardinality }
Endpoint information
type IAfter ¶
type IAfter interface {
After(data *Data, info *EndPointInfo) *webrender.RetVal
}
IAfter supports method to be called after data is after all CRUPD operations
type IAfterTransact ¶
type IAfterTransact interface {
AfterTransact(data *Data, info *EndPointInfo)
}
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 *EndPointInfo) *webrender.RetVal
}
IBefore supports method to be called before data is fetched for all CRUPD operations
type IBeforeApply ¶
type IBeforeApply interface {
BeforeApply(data *Data, info *EndPointInfo) *webrender.RetVal
}
IBeforeApply before patching operation occurred. Only called for Patch. This comes before patch is applied. Before "Before"
type IGuardAPIEntry ¶
type IGuardAPIEntry interface { // GuardAPIEntry returs false to block entry, and optional customRenderer // to return custom error code (Read enters this as well before having any model) GuardAPIEntry(data *Data, info *EndPointInfo) *webrender.GuardRetVal }
IGuardAPIEntry supports method which guard access to API based on scope
type IHasRenderer ¶
type IHasRenderer interface {
Render(c *gin.Context, data *Data, op *EndPointInfo) bool
}
IHasRenderer is for formatting IModel with a custom function basically do your own custom output If return false, use the default JSON output For batch renderer, register a Render(r UserRole, who models.UserIDFetchable, modelObjs []IModel) bool
type RESTOp ¶
type RESTOp int
Method designates the type of operations for BeforeCRUPD and AfterCRUPD hookpoints