fix default bug
This commit is contained in:
parent
e001c13a7c
commit
47b46118cd
3 changed files with 7 additions and 8 deletions
|
|
@ -1,3 +0,0 @@
|
|||
package main
|
||||
|
||||
// 服务设定
|
||||
|
|
@ -24,15 +24,15 @@ func (table *Table) loadAPIs() {
|
|||
|
||||
api := defaults[name]
|
||||
api.Name = name
|
||||
if table.APIs[name].Process == "" {
|
||||
if table.APIs[name].Process != "" {
|
||||
api.Process = table.APIs[name].Process
|
||||
}
|
||||
|
||||
if table.APIs[name].Guard == "" {
|
||||
if table.APIs[name].Guard != "" {
|
||||
api.Guard = table.APIs[name].Guard
|
||||
}
|
||||
|
||||
if table.APIs[name].Default == nil {
|
||||
if table.APIs[name].Default != nil {
|
||||
api.Default = table.APIs[name].Default
|
||||
}
|
||||
defaults[name] = api
|
||||
|
|
@ -137,12 +137,14 @@ func (api API) IsGuard(v interface{}) bool {
|
|||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
guards := strings.Split(api.Guard, ",")
|
||||
for _, guard := range guards {
|
||||
guard = strings.TrimSpace(guard)
|
||||
handler, has := gou.HTTPGuards[guard]
|
||||
if has {
|
||||
handler(c)
|
||||
fmt.Println(api.Guard, c.IsAborted())
|
||||
return c.IsAborted()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ func ProcessSearch(process *gou.Process) interface{} {
|
|||
// 合并默认查询参数
|
||||
func mergeQueryParam(param gou.QueryParam, api API, i int) gou.QueryParam {
|
||||
if len(api.Default) > i && api.Default[i] != nil {
|
||||
defaults, ok := api.Default[i].(gou.QueryParam)
|
||||
defaults, ok := gou.AnyToQueryParam(api.Default[i])
|
||||
if !ok {
|
||||
exception.New("参数默认值数据结构错误", 400).Throw()
|
||||
exception.New("参数默认值数据结构错误", 400).Ctx(api.Default[i]).Throw()
|
||||
}
|
||||
if defaults.Withs != nil {
|
||||
param.Withs = defaults.Withs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue