multi fixtures

master
Paulo Simão 2021-05-01 19:09:48 -03:00
parent b7124b259f
commit e307ce7669
3 changed files with 4 additions and 3 deletions

View File

@ -223,7 +223,7 @@ func addFunction(a *ast.FuncDecl) {
} }
if fn.Path == "" { if fn.Path == "" {
fn.Path = "/" + strings.ToLower(a.Name.Name) fn.Path = "/" + strings.Replace(strings.ToLower(a.Name.Name), "_", "/", -1)
} }
api.Methods[a.Name.Name] = &fn api.Methods[a.Name.Name] = &fn

View File

@ -66,8 +66,8 @@ func {{$methodname}}(req {{if $method.ReqType.IsArray}}[]{{end}}{{if $method.Re
if err!=nil{ if err!=nil{
return return
} }
var ret {{if $method.ResType.IsArray}}[]{{end}}{{if $method.ResType.Ispointer}}*{{end}}{{$method.ResType.Typename}} var ret {{if $method.ResType.IsArray}}[]{{end}}{{if $method.ResType.Ispointer}}*{{end}}{{$method.ResType.Typename}} {{if $method.ResType.Ispointer}} {{if ne $method.ResType.IsArray true}}=&{{$method.ResType.Typename}}{}{{end}}{{end}}
err = dec.Decode(ret) err = dec.Decode({{if $method.ResType.IsArray}}&{{end}} {{if ne $method.ResType.Ispointer true}}&{{end}}ret)
return ret, err return ret, err
} }
{{end}} {{end}}

View File

@ -37,6 +37,7 @@ func Build(r *gin.Engine) *gin.Engine {
{{- if $verb.Method.ReqType.Ispointer}} *{{ end -}} {{- if $verb.Method.ReqType.Ispointer}} *{{ end -}}
{{- $verb.Method.ReqType.Typename}} {{- $verb.Method.ReqType.Typename}}
{{- if or $verb.Method.ReqType.IsArray $verb.Method.ReqType.Ispointer}} {{- if or $verb.Method.ReqType.IsArray $verb.Method.ReqType.Ispointer}}
{{- if $verb.Method.ReqType.Ispointer}} = &{{- $verb.Method.ReqType.Typename}}{}{{ end}}
c.BindJSON(req) c.BindJSON(req)
{{else}} {{else}}
c.BindJSON(&req) c.BindJSON(&req)