Documentation ¶
Index ¶
- Variables
- func GenDoc(profile *Profile, routePrefixs *RoutePrefixs, apis ...string) *[]Doc
- type API
- func (ai *API) ALL(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Create(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Delete(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Feature(name string) *API
- func (ai *API) FeatureWithOpts(opts *Opts) *API
- func (ai *API) List(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) One(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- func (ai *API) Update(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
- type CreateHook
- type DeleteHook
- type Doc
- type Example
- type Fields
- type FieldsParameter
- type Hook
- type ListHook
- type M
- type Model
- type Mongo
- func (e *Mongo) Conf(conf *mgo.DialInfo) *Mongo
- func (e *Mongo) Docs() *[]Doc
- func (e *Mongo) Init(init func(*Mongo)) *Mongo
- func (e *Mongo) Model(name string) *mgo.Collection
- func (e *Mongo) Plugin(r *gin.RouterGroup) *Mongo
- func (e *Mongo) Profile(name string) *Profile
- func (e *Mongo) Register(profile *Profile) *Mongo
- func (e *Mongo) Var(name string) interface{}
- func (e *Mongo) Vars(name string) interface{}
- type OneHook
- type Opts
- type Parameter
- type PreloadInfo
- type Profile
- type Query
- type RouteHooks
- type RoutePrefixs
- type UpdateHook
Constants ¶
This section is empty.
Variables ¶
var FailureHandler = func(c *gin.Context) { c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{ "message": "Access Denied, you don't have permission", }) }
FailureHandler handlerss
Functions ¶
Types ¶
type API ¶
type API struct { Opts *Opts // contains filtered or unexported fields }
API type defined
func (*API) ALL ¶
func (ai *API) ALL(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
ALL hook auto generate api
func (*API) Create ¶
func (ai *API) Create(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Create hook auto generate api
func (*API) Delete ¶
func (ai *API) Delete(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Delete hook auto generate api
func (*API) FeatureWithOpts ¶
FeatureWithOpts defined feature api with opts
func (*API) List ¶
func (ai *API) List(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
List hook auto generate api
func (*API) One ¶
func (ai *API) One(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
One hook auto generate api
func (*API) Update ¶
func (ai *API) Update(r *gin.RouterGroup, name string, handlers ...gin.HandlerFunc) *Hook
Update hook auto generate api
type CreateHook ¶
type CreateHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Form func(form) form }
CreateHook defined create hook opts
type DeleteHook ¶
type DeleteHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Form func(form) form Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
DeleteHook defined delete hook opts
type Doc ¶
type Doc struct { Type string `json:"type" yaml:"type"` URL string `json:"url" yaml:"url"` Title string `json:"title" yaml:"title"` Name string `json:"name" yaml:"name"` Group string `json:"group" yaml:"group"` Desc string `json:"description" yaml:"description"` Version string `json:"version" yaml:"version"` GroupTitle string `json:"groupTitle" yaml:"groupTitle"` Parameter Parameter `json:"parameter" yaml:"parameter"` }
Doc defined model api doc
type Example ¶
type Example struct { Title string `json:"title" yaml:"title"` Content string `json:"content" yaml:"content"` Type string `json:"type" yaml:"type"` }
Example defined model api doc
type Fields ¶
type Fields struct {
FieldsParameter []FieldsParameter `json:"Parameter" yaml:"Parameter"`
}
Fields defined model api doc
type FieldsParameter ¶
type FieldsParameter struct { Tags reflect.StructTag `json:"-" yaml:"-"` Group string `json:"group" yaml:"group"` Type string `json:"type" yaml:"type"` Optional bool `json:"optional" yaml:"optional"` Field string `json:"field" yaml:"field"` Desc string `json:"description" yaml:"description"` }
FieldsParameter defined model api doc
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook for API
func (*Hook) RouteHooks ¶
func (h *Hook) RouteHooks(hooks *RouteHooks) *Hook
RouteHooks defined RouteHooks
type ListHook ¶
type ListHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(*gin.Context) bool Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
ListHook defined list hook opts
type Model ¶
type Model struct { ID bson.ObjectId `bson:"_id,omitempty" br:"comment:'模型ID'"` CreatedAt *time.Time `bson:"_created" br:"comment:'创建时间'"` UpdatedAt *time.Time `bson:"_updated" br:"comment:'修改时间'"` DeletedAt *time.Time `bson:"_deleted" br:"comment:'删除时间'"` }
Model common fields
type Mongo ¶
Mongo Type Defined
func (*Mongo) Model ¶
func (e *Mongo) Model(name string) *mgo.Collection
Model return instance throw error if not exists these model
func (*Mongo) Plugin ¶
func (e *Mongo) Plugin(r *gin.RouterGroup) *Mongo
Plugin defined plugin for bulrush
type OneHook ¶
type OneHook struct { Pre func(*gin.Context) Post func(*gin.Context) Auth func(c *gin.Context) bool Cond func(map[string]interface{}, *gin.Context, struct{ Name string }) map[string]interface{} }
OneHook defined one hook opts
type Opts ¶
type Opts struct { Prefix string FeaturePrefix string RoutePrefixs *RoutePrefixs RouteHooks *RouteHooks }
Opts defined api params
type Parameter ¶
type Parameter struct { Fields Fields `json:"fields" yaml:"fields"` Examples []Example `json:"examples" yaml:"examples"` }
Parameter defined model api doc
type PreloadInfo ¶
type PreloadInfo struct { BsonName string IsArray bool Coll string Local string Foreign string Up string }
PreloadInfo defined preload unit
type Profile ¶
type Profile struct { DB string Collection string Name string Reflector interface{} AutoHook bool Opts *Opts // contains filtered or unexported fields }
Profile defined model profile
type Query ¶
type Query struct { Query struct { Cond string `form:"cond" json:"cond" xml:"cond"` Project string `form:"project" json:"project" xml:"project"` UProject string `form:"uproject" json:"uproject" xml:"uproject"` Preload string `form:"preload" json:"preload" xml:"preload"` Order string `form:"order" json:"order" xml:"order"` Page int `form:"page" json:"page" xml:"page"` Size int `form:"size" json:"size" xml:"size"` Range string `form:"range" json:"range" xml:"range"` } Cond map[string]interface{} Pipe []M Project map[string]interface{} UProject map[string]interface{} Preload string Order map[string]interface{} Page int Size int Range string // contains filtered or unexported fields }
Query defined query std
func (*Query) BuildRelated ¶
BuildRelated defined related sql for preLoad
func (*Query) BuildUProject ¶
func (q *Query) BuildUProject()
BuildUProject dfined build select fields
type RouteHooks ¶
type RouteHooks struct { One *OneHook List *ListHook Create *CreateHook Update *UpdateHook Delete *DeleteHook }
RouteHooks defined route hooks