Documentation
¶
Index ¶
- type Action
- type Hook
- type Params
- type Resource
- func (r *Resource) Create(obj interface{}, req api2go.Request) (api2go.Responder, error)
- func (r *Resource) Delete(id string, req api2go.Request) (api2go.Responder, error)
- func (r *Resource) FindAll(req api2go.Request) (api2go.Responder, error)
- func (r *Resource) FindOne(ID string, req api2go.Request) (api2go.Responder, error)
- func (r *Resource) Update(obj interface{}, req api2go.Request) (api2go.Responder, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action int
Action indicates the type of action being performed.
const ( // BeforeCreate indicates that a resource is about to be created. BeforeCreate Action = iota // AfterCreate indicates that a resource has been created. AfterCreate // BeforeDelete indicates that a resource is about to be destroyed. BeforeDelete // AfterDelete indicates that a resource has been destroyed. AfterDelete // BeforeUpdate indicates that a resource is about to be modified. BeforeUpdate // AfterUpdate indicates that a resource has been modified. AfterUpdate // BeforeFindAll indicates that multiple resources are about to be retrieved. BeforeFindAll // AfterFindAll indicates that multiple resources may have been retrieved. AfterFindAll // BeforeFindOne indicates that a single resource is about to be retrieved. BeforeFindOne // AfterFindOne indicates that a single resource may have been retrieved. AfterFindOne )
type Hook ¶
Hook is a callback that is run immediately before processing each action. If the hook returns an error, the action does not run.
type Params ¶
Params contains information about an API request. Only certain members will contain valid data, depending on the action.
type Resource ¶
type Resource struct {
// DB is a pointer to an open database connection.
DB *gorm.DB
// Type is an instance of the model for this resource.
Type interface{}
// Hooks is a list of callbacks to run before each action.
Hooks []Hook
// Fields is a list of valid field names for filtering.
Fields []string
}
Resource implements the interfaces necessary to use a GORM model with the api2go package.
Click to show internal directories.
Click to hide internal directories.