更新handler的返回值
This commit is contained in:
parent
61c10dab23
commit
44edea6b51
|
@ -10,13 +10,13 @@ import (
|
||||||
{{if eq .MethodType "rpc"}}
|
{{if eq .MethodType "rpc"}}
|
||||||
|
|
||||||
func (l *{{.StructName}}) {{.MethodName}}Logic({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (resp {{.MethodReturn}},err error) {
|
func (l *{{.StructName}}) {{.MethodName}}Logic({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (resp {{.MethodReturn}},err error) {
|
||||||
return resp, err
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
{{else if eq .MethodType "stream"}}
|
{{else if eq .MethodType "stream"}}
|
||||||
|
|
||||||
func (l *{{.StructName}}) {{.MethodName}}Logic(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (err error) {
|
func (l *{{.StructName}}) {{.MethodName}}Logic(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (err error) {
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package {{.PackageName}}
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"fusen-basic/env"
|
"fusen-basic/env"
|
||||||
|
|
||||||
|
@ -47,13 +48,24 @@ type {{.MethodName}}HandlerMust struct{}
|
||||||
|
|
||||||
{{if eq .MethodType "rpc"}}
|
{{if eq .MethodType "rpc"}}
|
||||||
|
|
||||||
func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) ({{.MethodReturn}}, error) {
|
func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (_resp {{.MethodReturn}},_err error) {
|
||||||
|
defer func() {
|
||||||
|
if _recoverErr := recover(); _recoverErr != nil {
|
||||||
|
_resp = nil
|
||||||
|
_err = fmt.Errorf("%v", _recoverErr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
return New{{.StructName}}(ctx).{{.MethodName}}Logic({{range $index, $param := .ParamsName}}{{if $index}}, {{end}}{{$param}}{{end}})
|
return New{{.StructName}}(ctx).{{.MethodName}}Logic({{range $index, $param := .ParamsName}}{{if $index}}, {{end}}{{$param}}{{end}})
|
||||||
}
|
}
|
||||||
|
|
||||||
{{else if eq .MethodType "stream"}}
|
{{else if eq .MethodType "stream"}}
|
||||||
|
|
||||||
func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) error {
|
func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (_err error) {
|
||||||
|
defer func() {
|
||||||
|
if _recoverErr := recover(); _recoverErr != nil {
|
||||||
|
_err = fmt.Errorf("%v", _recoverErr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
return New{{.StructName}}(stream.Context()).{{.MethodName}}Logic(stream)
|
return New{{.StructName}}(stream.Context()).{{.MethodName}}Logic(stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user