Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 `json:"typeString"` URL string `json:"url"` Op rest.Op `json:"op"` Cardinality rest.Cardinality `json:"cardinality"` // URL parameters URLParams map[urlparam.Param]interface{} `json:"urlParams"` // Who is operating this CRUPD right now Who mdlutil.UserIDFetchable `json:"who"` }
Endpoint information
type IAfterTransact ¶
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 ¶
IBefore supports method to be called before data is fetched for all operations except Read
type IBeforeApply ¶
IBeforeApply before patching operation occurred. Only called for Patch. This comes before patch is applied. Before "Before"
type ICache ¶ added in v0.10.1
type ICache interface { // Get data by info. If exists, can be implemented to avoid hitting the database in read endpoints // if boolean is false, it means it is not handled and database query will be proceeded // unless another hook which implemented this takes over. // A maximum of one handler is used at a time, the hook writer has to make sure they are mutally exclusive // if found is false, it means it was not found in the database (only used for query with cardinality of 1) GetFromCache(info *EndPoint) (handled bool, found bool, ms []mdl.IModel, roles []userrole.UserRole, no *int, retErr *webrender.RetError) // A maximum of one handler is used at a time, the hook writer has to make sure they are mutally exclusive // if found is false, it means it was not found in the database and the negative result is to be cached. AddToCache(info *EndPoint, found bool, ms []mdl.IModel, roles []userrole.UserRole, no *int) (handled bool, retErr *webrender.RetError) }
ICache supports cache.
type IHook ¶
type IHook interface { // Init data for this REST operation // (TODO: But role doesn't exists yet before read, and I can't seem to find any use for any of these data) Init(data *InitData, args ...interface{}) }
Click to show internal directories.
Click to hide internal directories.