You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use `vtprotobuf` with Connect simply pass in `connect.WithCodec(grpc.Codec{})` as a connect option to the client and handler constructors.
183
+
To use `vtprotobuf` with Connect, first implement a custom codec in your own project that serializes messages based on their type (see [Mixing ProtoBuf implementations with GRPC](#mixing-protobuf-implementations-with-grpc)). This is required because Connect internally serializes some types such as `Status` that don't have `vtprotobuf` helpers. Then pass in `connect.WithCodec(mygrpc.Codec{})` as a connect option to the client and handler constructors.
184
184
185
185
```go
186
186
package main
@@ -190,21 +190,21 @@ import (
190
190
191
191
"github.com/bufbuild/connect-go"
192
192
"github.com/foo/bar/pingv1connect"
193
-
"github.com/planetscale/vtprotobuf/codec/grpc"
193
+
"github.com/myorg/myproject/codec/mygrpc"
194
194
)
195
195
196
196
funcmain() {
197
197
mux:= http.NewServeMux()
198
198
mux.Handle(pingv1connect.NewPingServiceHandler(
199
199
&PingServer{},
200
-
connect.WithCodec(grpc.Codec{}), // Add connect option to handler.
200
+
connect.WithCodec(mygrpc.Codec{}), // Add connect option to handler.
201
201
))
202
202
// handler serving ...
203
203
204
204
client:= pingv1connect.NewPingServiceClient(
205
205
http.DefaultClient,
206
206
"http://localhost:8080",
207
-
connect.WithCodec(grpc.Codec{}), // Add connect option to client.
207
+
connect.WithCodec(mygrpc.Codec{}), // Add connect option to client.
0 commit comments