connectcompat

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause-Clear Imports: 6 Imported by: 0

Documentation

Overview

Package connectcompat bridges connect-go v1 and v2 for services that serve on v2 while calling other services through v1 clients, such as the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeOf

func CodeOf(err error) connect.Code

CodeOf returns the code of the first connect-go v2 or v1 error in err's chain, or connect.CodeUnknown when there is none. connect.CodeOf does not recognize v1 errors, which v2 handlers receive from v1 clients.

func HTTPHeader

func HTTPHeader(header *connect.Header) http.Header

HTTPHeader copies a connect-go v2 header into an http.Header.

func RequestHeader

func RequestHeader(ctx context.Context) http.Header

RequestHeader returns a copy of the request headers of the server call in ctx, or an empty header when ctx carries no call.

func ServerInterceptor

func ServerInterceptor() connect.ServerInterceptor

ServerInterceptor sends handler errors to clients the way connect-go v1 handlers did. connect-go v2 sends a locally created *connect.Error as written but sends any other error, including v1 errors and errors received from a remote v2 service, as a bare code with no message.

func ToV2Error

func ToV2Error(ctx context.Context, err error) error

ToV2Error returns err as an error that a connect-go v2 server sends with the code, message, and details a v1 handler would have sent. Metadata on a v1 error becomes response headers of the call in ctx. A nil error and a locally created v2 error are returned unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

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