https://github.com/akshayjshah/connectproto
Configurable codecs for connect-go
https://github.com/akshayjshah/connectproto
connectrpc json protobuf
Last synced: 11 months ago
JSON representation
Configurable codecs for connect-go
- Host: GitHub
- URL: https://github.com/akshayjshah/connectproto
- Owner: akshayjshah
- License: mit
- Created: 2023-04-29T21:29:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-10T11:50:34.000Z (over 2 years ago)
- Last Synced: 2025-04-10T19:16:54.624Z (about 1 year ago)
- Topics: connectrpc, json, protobuf
- Language: Go
- Homepage: https://pkg.go.dev/go.akshayshah.org/connectproto
- Size: 33.2 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-connect - connectproto - Customize the default JSON and binary codecs from [Connect-Go](https://github.com/connectrpc/connect-go). (Go)
README
connectproto
============
[](https://github.com/akshayjshah/connectproto/actions/workflows/ci.yaml)
[](https://goreportcard.com/report/go.akshayshah.org/connectproto)
[](https://pkg.go.dev/go.akshayshah.org/connectproto)
`connectproto` allows [Connect][connect] users to customize the default JSON
and binary codecs. It also includes support for the optimized marshaling
methods generated by [vtprotobuf].
## Installation
```
go get go.akshayshah.org/connectproto
```
## Usage
Use this package's options just like the ones built into `connect-go`:
```go
opt := connectproto.WithJSON(
protojson.MarshalOptions{UseProtoNames: true},
protojson.UnmarshalOptions{DiscardUnknown: true},
)
// The pingv1connect package is generated from your Protocol Buffer schemas
// by protoc-gen-connect-go. You can use connectproto options with
// both handlers and clients.
route, handler := pingv1connect.NewPingServiceHandler(
&pingv1connect.UnimplementedPingServiceHandler{},
opt,
)
client := pingv1connect.NewPingServiceClient(
http.DefaultClient,
"https://localhost:8080",
opt,
)
```
## Status: Unstable
This module is unstable, with a stable release expected before the end of 2023.
It supports:
* The [two most recent major releases][go-support-policy] of Go.
* [APIv2] of Protocol Buffers in Go (`google.golang.org/protobuf`).
Within those parameters, `connectproto` follows semantic versioning.
## Legal
Offered under the [MIT license][license].
[APIv2]: https://blog.golang.org/protobuf-apiv2
[go-support-policy]: https://golang.org/doc/devel/release#policy
[license]: https://github.com/akshayjshah/connectproto/blob/main/LICENSE
[connect]: https://github.com/connectrpc.com/connect-go
[vtprotobuf]: https://github.com/planetscale/vtprotobuf