diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl index cb3b769..b970831 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl @@ -19,22 +19,24 @@ type Endpoints struct { } {{range .Service.Method}} -func (e *Endpoints){{.Name}}(ctx context.Context, in *pb.{{.Name}}Request) (*pb.{{.Name}}Response, error) { +/*{{. | prettyjson}}*/ + +func (e *Endpoints){{.Name}}(ctx context.Context, in *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, error) { out, err := e.{{.Name}}Endpoint(ctx, in) if err != nil { - return &pb.{{.Name}}Response{ErrMsg: err.Error()}, err + return &pb.{{.OutputType | splitArray "." | last}}{ErrMsg: err.Error()}, err } - return out.(*pb.{{.Name}}Response), err + return out.(*pb.{{.OutputType | splitArray "." | last}}), err } {{end}} {{range .Service.Method}} func Make{{.Name}}Endpoint(svc pb.{{$file.Package | title}}ServiceServer) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(*pb.{{.Name}}Request) + req := request.(*pb.{{.InputType | splitArray "." | last}}) rep, err := svc.{{.Name}}(ctx, req) if err != nil { - return &pb.{{.Name}}Response{ErrMsg: err.Error()}, err + return &pb.{{.OutputType | splitArray "." | last}}{ErrMsg: err.Error()}, err } return rep, nil } diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl index 14e8ca4..5062394 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl @@ -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}} diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl index a57eb6b..cf27b2a 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl @@ -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 }