Documentation
¶
Index ¶
- 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 MysqlConfig
- type MysqlInstance
- type RedisConfig
- type RedisInstance
- type RestApi
- type SingleModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsZeroOfUnderlyingType ¶ added in v1.1.9
func IsZeroOfUnderlyingType(x interface{}) bool
func LimitHandler ¶ added in v1.3.2
Types ¶
type Config ¶
type Config struct {
Party iris.Party
MysqlInstance
RedisInstance
Models []*SingleModel
ErrorTrace func(err error, event, from, router string) // error trace func
}
config
type MysqlConfig ¶ added in v1.3.0
type MysqlInstance ¶ added in v1.3.0
type MysqlInstance struct {
MysqlConfig
Mdb *xorm.Engine
}
type RedisConfig ¶ added in v1.3.0
type RedisInstance ¶ added in v1.3.0
type RedisInstance struct {
RedisConfig
Rdb *redis.Client
}
type RestApi ¶ added in v1.3.0
type RestApi struct {
C *Config
}
func (*RestApi) DeleteData ¶ added in v1.3.0
DeleteData 删除数据 /{id:uint64}
func (*RestApi) GetAllFunc ¶ added in v1.3.0
GetAllFunc 获取所有 page控制页码 page_size控制条数 最大均为100 100页 100条 order(asc) order_desc search搜索 __会被替换为% eg:search=__赵日天 sql会替换为 %赵日天 filter_[字段名] 进行过滤 eg:filter_id=1 and的关系 or_[字段名] 进行过滤 eg:or_id=2 or的关系 使用header的Cache-control no-cache 跳过缓存
type SingleModel ¶ added in v1.1.5
type SingleModel struct {
Middlewares []context.Handler
Prefix string // 路由前缀
Suffix string // 路由后缀
Model interface{} // xorm model
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名称
GetAllFunc func(ctx iris.Context) // 覆盖获取全部方法
GetAllResponse interface{} // 获取所有返回的内容替换 仅替换data数组 同名替换
GetAllResponseFunc func(ctx iris.Context, result iris.Map, dataList []map[string]string) iris.Map // 返回内容替换的方法
GetAllExtraFilters map[string]string // 额外的固定过滤 key(数据库列名) 和 value 若与请求过滤重复则覆盖 优先级最高
GetAllMustFilters map[string]string // 获取全部必须拥有筛选
GetSingleFunc func(ctx iris.Context) // 覆盖获取单条方法
GetSingleResponse interface{} // 获取单个返回的内容替换
GetSingleResponseFunc func(ctx iris.Context, item interface{}) interface{} // 获取单个返回内容替换的方法
GetSingleExtraFilters map[string]string // 额外的固定过滤 key(数据库列名) 和 value 若与请求过滤重复则覆盖 优先级最高
PostFunc func(ctx iris.Context) // 覆盖新增方法
PostValidator interface{} // 新增自定义验证器
PostResponseFunc func(ctx iris.Context, item interface{}) interface{} //
PostResponse interface{} // 新增返回内容
PostDataParse func(ctx iris.Context, raw interface{}) interface{} //
PutFunc func(ctx iris.Context) // 覆盖修改方法
PutValidator interface{} // 修改验证器
PutResponse interface{} // 修改返回内容
DeleteFunc func(ctx iris.Context) // 覆盖删除方法
DeleteValidator interface{} // 删除验证器
DeleteResponse interface{} // 删除返回内容
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 int // max page size limit
MaxPageCount int // 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.