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
get-requestGET request support for idempotent unary RPCs
idempotency-getAutomatic GET support via proto idempotency_level = NO_SIDE_EFFECTS

Tonic/gRPC Integration

ExampleDescription
tonic-unaryConnect + gRPC unary (dual protocol)
tonic-server-streamConnect + gRPC streaming (dual protocol)
tonic-bidi-streamBidirectional streaming (gRPC only)
tonic-extractorMultiple extractors with TonicCompatibleBuilder
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

Protocol Features

ExampleDescription
timeoutConnect-Timeout-Ms header handling
protocol-versionConnect-Protocol-Version header validation
streaming-compressionPer-message compression in streaming responses
client-streaming-compressionPer-message decompression in streaming requests

Running Examples

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

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.