更新handler的返回值
This commit is contained in:
parent
61c10dab23
commit
44edea6b51
|
@ -10,13 +10,13 @@ import (
|
|||
{{if eq .MethodType "rpc"}}
|
||||
|
||||
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"}}
|
||||
|
||||
func (l *{{.StructName}}) {{.MethodName}}Logic(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) (err error) {
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
|
|
@ -4,6 +4,7 @@ package {{.PackageName}}
|
|||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"fmt"
|
||||
|
||||
"fusen-basic/env"
|
||||
|
||||
|
@ -47,14 +48,25 @@ type {{.MethodName}}HandlerMust struct{}
|
|||
|
||||
{{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}})
|
||||
}
|
||||
|
||||
{{else if eq .MethodType "stream"}}
|
||||
|
||||
func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}(stream {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param}}{{end}}) error {
|
||||
return New{{.StructName}}(stream.Context()).{{.MethodName}}Logic(stream)
|
||||
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)
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user