Expand description
This crate gives a high level API to execute external HTTP requests.
It is supposed to give the basics building blocks for building bridges to other services while abstracting the low level stuff like adding custom headers and request tracing.
It supports both REST and GraphQL requests.
You should start by creating a Bridge instance. This instance should live for all the application lifetime.
Do not create a new bridge on every request!
You should use something like once_cell or lazy_static, or some sort of inversion of control container to pass around.
The bridge implement a type state pattern to build the external request.
§Features
auth0
- enable auth0 integration, allowing bridge.rs to retrieve tokens from auth0 for authenticationgzip
- provides response body gzip decompression.redis-tls
- add support for connecting to redis with tlsgrpc
- provides the GrpcOtelInterceptor for adding the opentelemetry context to the gRPC requeststracing_opentelemetry
- adds support for integration with opentelemetry. This feature is an alias for the latesttracing_opentelemetry_x_xx
feature.tracing_opentelemetry_x_xx
(e.g.tracing_opentelemetry_0_27
) - adds support for integration with a particular opentelemetry version. We are going to support at least the last 3 versions of opentelemetry. After that we might remove support for older otel version without it being a breaking change.
Re-exports§
pub use self::builder::BridgeBuilder;
Modules§
Structs§
- Body
- A request body.
- Bridge
Impl - A Bridge instance that’s generic across the client. If the BridgeBuilder is used to construct a bridge with middleware, this type will be used to wrap the reqwest_middleware::ClientWithMiddleware.
- Error
- A struct representing a GraphQL error according to the GraphQL specification.
- GraphQL
Request - The GraphQLRequest is a struct that represent a GraphQL request to be done with a crate::Bridge.
- Grpc
Otel Interceptor grpc
- A gRPC interceptor that injects the current tracing context into the request metadata.
- Multipart
File - A multipart-form file, containing the file’s desired name, its MIME type, and its contents as an in-memory buffer or stream.
- Multipart
Form File Field - A named multipart-form field which contains a file.
- Request
- A utility type to construct requests more easily.
- Response
- A server response.
- Rest
Request - The RestRequest is a struct that represent a REST request to be done with a crate::Bridge.
Enums§
- GraphQL
Multipart - A GraphQLRequest multipart body as according to this specification.
- Possibly
Parsed Data - An error type to represent all possible outcomes of a GraphQL response deserialization.
- Redirect
Policy - Determines how to handle HTTP redirects (3xx responses).
- Rest
Multipart - A RestRequest multipart form body.
Traits§
- Deliverable
Request - Represents a request that is ready to be delivered to the server.
- Parsed
Graphql Response Ext
Type Aliases§
- Bridge
- The basic Bridge type, using a reqwest::Client as the client.
- Grpc
Otel Intercepted Service grpc
- Convenience type alias for a long type that’s returned from the
with_interceptor()
function of the tonic-generated gRPC client when used with GrpcOtelInterceptor. - Parsed
Graphql Response - A type returned from parse_graphql_response function useful for getting full control of a GraphQL response.