Better reliability on generated message names
This commit is contained in:
@@ -40,12 +40,12 @@ type grpcServer struct {
|
||||
}
|
||||
|
||||
{{range .Service.Method}}
|
||||
func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.Name}}Request) (*pb.{{.Name}}Response, error) {
|
||||
func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, error) {
|
||||
_, rep, err := s.{{.Name | lower}}.ServeGRPC(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rep.(*pb.{{.Name}}Response), nil
|
||||
return rep.(*pb.{{.OutputType | splitArray "." | last}}), nil
|
||||
}
|
||||
|
||||
func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -53,7 +53,7 @@ func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface
|
||||
}
|
||||
|
||||
func encode{{.Name}}Response(ctx context.Context, response interface{}) (interface{}, error) {
|
||||
resp := response.(*pb.{{.Name}}Response)
|
||||
resp := response.(*pb.{{.OutputType | splitArray "." | last}})
|
||||
return resp, nil
|
||||
}
|
||||
{{end}}
|
||||
|
@@ -26,7 +26,7 @@ func Make{{.Name}}Handler(ctx context.Context, svc pb.{{$file.Package | title}}S
|
||||
}
|
||||
|
||||
func decode{{.Name}}Request(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
var req pb.{{.Name}}Request
|
||||
var req pb.{{.InputType | splitArray "." | last}}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user