Documentation
¶
Index ¶
- func DiffBson(origin interface{}, news interface{}, params map[string][]string, ...) (bson.M, bson.M)
- func FilterFormValues(params map[string][]string) map[string][]string
- func IsNum(s string) bool
- func IsZeroOfUnderlyingType(x interface{}) bool
- func LimitHandler(l *limiter.Limiter, errBack ...func(*errors.HTTPError, iris.Context)) iris.Handler
- func Replace(origin, newData interface{}) error
- type Config
- type RestApi
- type SingleModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiffBson ¶
func DiffBson(origin interface{}, news interface{}, params map[string][]string, structDelimiter string) (bson.M, bson.M)
DiffBson 两个bson.m 对比 获取异同
func FilterFormValues ¶ added in v0.1.10
FilterFormValues 重新获取params
func IsZeroOfUnderlyingType ¶
func IsZeroOfUnderlyingType(x interface{}) bool
func LimitHandler ¶
Types ¶
type Config ¶
type Config struct {
Party iris.Party
Mdb *qmgo.Database
Models []*SingleModel
ErrorTrace func(err error, event, from, router string) // error trace func
PrivateContextKey string
PrivateColName string
StructDelimiter string // 内联struct之间的分隔符 默认__ 因为.号会被转义 不要使用. _
}
config
type RestApi ¶
type RestApi struct {
C *Config
}
func (*RestApi) DeleteData ¶
DeleteData 删除数据 /{mid:string range(1,32)}
func (*RestApi) GetAllFunc ¶
GetAllFunc 获取所有 page 控制页码 page_size 控制条数 最大均为100 100页 100条 _last mid 大页码通用 _o(asc) _od _s __在左右则为模糊 _s=__赵日天 [字段名] 进行过滤 id=1 最长64位请注意 and关系 _o_[字段名] 进行过滤 _o_id=2 最长64位 or关系
type SingleModel ¶
type SingleModel struct {
Prefix string // 路由前缀
Suffix string // 路由后缀
Model interface{} // xorm model
Pk func() []bson.D // 外键
DisablePrivate bool // 禁用私密参数
PrivateContextKey string // 上下文key string int uint
PrivateColName string // 数据库字段名 MapName or ColName is ok
AllowMethods []string // allow methods first
DisableMethods []string // get(all) get(single) post put delete
AllowSearchFields []string // 搜索的字段 struct名称
GetAllResponseFunc func(ctx iris.Context, result iris.Map, dataList []map[string]interface{}) iris.Map // 返回内容替换的方法
GetAllExtraFilters func(ctx iris.Context) map[string]interface{} // 额外的固定过滤 key(数据库列名) 和 value 若与请求过滤重复则覆盖 优先级最高
GetAllMustFilters map[string]string // 获取全部必须拥有筛选
GetSingleResponseFunc func(ctx iris.Context, item map[string]interface{}) map[string]interface{} // 获取单个返回内容替换的方法
GetSingleExtraFilters func(ctx iris.Context) map[string]interface{} // 额外的固定过滤 key(数据库列名) 和 value 若与请求过滤重复则覆盖 优先级最高
GetSingleMustFilters map[string]string // 获取单个必须拥有筛选
PostValidator interface{} // 新增自定义验证器
PostMustFilters map[string]string // 新增必须存在的参数
PostResponseFunc func(ctx iris.Context, mid string, item interface{}) interface{} //
PostDataParse func(ctx iris.Context, raw interface{}) interface{} //
PutValidator interface{} // 修改验证器
PutDataParse func(ctx iris.Context, mid string, diff bson.M) bson.M //
PutQueryParse func(ctx iris.Context, mid string, query bson.M, formData map[string][]string, privateValue interface{}) bson.M // 修改的时候query可以自定义修改
PutResponseFunc func(ctx iris.Context, mid string) iris.Map // 在修改之前还可以变更一下数据
PutMustFilters map[string]string //
DeleteValidator interface{} // 删除验证器
DeleteResponseFunc func(ctx iris.Context, mid string, item map[string]interface{}, result iris.Map) iris.Map //
CacheTime time.Duration // full cache time
GetAllCacheTime time.Duration // get all cache time
GetSingleCacheTime time.Duration // get single cache time
DelayDeleteTime time.Duration // 延迟多久双删 default 500ms
MaxPageSize int64 // max page size limit
MaxPageCount int64 // max page count limit
RateErrorFunc func(*tollerr.HTTPError, iris.Context) //
Rate *limiter.Limiter // all
GetAllRate *limiter.Limiter //
GetSingleRate *limiter.Limiter //
AddRate *limiter.Limiter //
PutRate *limiter.Limiter //
DeleteRate *limiter.Limiter //
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.