Skip to content

Examples

See the connectrpc-axum-examples directory for complete working examples.

Connect Protocol

ExampleDescription
connect-unaryPure Connect unary RPC
connect-server-streamPure Connect server streaming
connect-client-streamPure Connect client streaming
connect-bidi-streamPure Connect bidirectional streaming

Tonic/gRPC Integration

ExampleDescription
tonic-unaryConnect + gRPC unary (dual protocol)
tonic-server-streamConnect + gRPC streaming (dual protocol)
tonic-bidi-streamBidirectional streaming (gRPC only)
grpc-webgRPC-Web browser support

Error Handling

ExampleDescription
error-detailsReturning google.rpc error details (e.g., RetryInfo)
extractor-connect-errorExtractor rejection with ConnectError
extractor-http-responseExtractor rejection with plain HTTP response
unary-error-metadataUnary errors with custom metadata headers
endstream-metadataEndStream frame metadata in streaming
streaming-error-reproStreaming error handling demonstration

Compression

ExampleDescription
streaming-compressionPer-message compression in streaming responses
client-streaming-compressionPer-message decompression in streaming requests
streaming-compression-algosStreaming compression with all algorithms
client-streaming-compression-algosClient streaming decompression with all algorithms
unary-compression-algosUnary compression with all algorithms

Connect RPC Client

ExampleDescription
client/unary-clientBasic unary RPC client
client/server-stream-clientServer streaming client
client/client-stream-clientClient streaming client
client/bidi-stream-clientBidirectional streaming client
client/typed-clientType-safe generated client
client/streaming-interceptor-clientStreaming with interceptors
client/message-interceptor-clientMessage-level interceptor
client/typed-interceptor-clientTyped interceptor on generated clients

Running Examples

bash
cd connectrpc-axum-examples
cargo run --bin connect-unary

For client examples:

bash
# Start a server first
cargo run --bin connect-unary &

# Run the client
cargo run --bin unary-client

For examples with tonic features:

bash
cargo run --bin tonic-unary --features tonic
cargo run --bin grpc-web --features tonic-web

Released under the MIT License.