connectproto

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 8 Imported by: 0

README

connectproto

Build Report Card GoDoc

connectproto allows 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:

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:

Within those parameters, connectproto follows semantic versioning.

Offered under the MIT license.

Documentation

Overview

Package connectproto provides configurable codecs for Connect clients and handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBinary added in v0.2.0

func WithBinary(marshal proto.MarshalOptions, unmarshal proto.UnmarshalOptions) connect.Option

WithBinary customizes a connect-go Client or Handler's binary protobuf handling, using any options supported by google.golang.org/protobuf.

func WithBinaryVT added in v0.3.0

func WithBinaryVT() connect.Option

WithBinaryVT customizes a connect-go Client or Handler's binary protobuf handling, using the optimized marshaling and unmarshaling methods produced by vtprotobuf where possible. If the methods generated by vtprotobuf aren't available, the codec falls back to google.golang.org/protobuf with the default options.

func WithJSON

func WithJSON(marshal protojson.MarshalOptions, unmarshal protojson.UnmarshalOptions) connect.Option

WithJSON customizes a connect-go Client or Handler's JSON handling.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL