20 releases (5 stable)
| 1.4.0 | Oct 14, 2025 |
|---|---|
| 1.1.1 | Apr 24, 2024 |
| 1.0.0 | Jan 16, 2024 |
| 0.6.0 | Nov 15, 2023 |
| 0.3.1 | Dec 8, 2022 |
#178 in HTTP server
472 downloads per month
18KB
483 lines
Flipt Rust
This directory contains the Rust source code for the Flipt server-side client.
Documentation
API documentation is available at https://www.flipt.io/docs/reference/overview.
Installation
cargo add flipt
Usage
In your Rust code you can import this client and use it as so:
use std::collections::HashMap;
use flipt::api::FliptClient;
use flipt::evaluation::models::EvaluationRequest;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FliptClient::default();
let mut context: HashMap<String, String> = HashMap::new();
context.insert("fizz".into(), "buzz".into());
let variant_result = client
.evaluation
.variant(&EvaluationRequest {
namespace_key: "default".into(),
flag_key: "flag1".into(),
entity_id: "entity".into(),
context: context.clone(),
reference: None,
})
.await
.unwrap();
print!("{:?}", variant_result);
There is a more detailed example in the examples directory.
Setting HTTP Headers
You can set custom HTTP headers for the client by using the with_headers method in the ConfigBuilder.
let client = FliptClient::new(ConfigBuilder::default().with_headers(HeaderMap::new()).build());
Flipt V2 Environment Support
Flipt V2 introduces the concept of environments. This client supports evaluation of flags in a specific environment by using the X-Flipt-Environment header.
let client = FliptClient::new(ConfigBuilder::default().with_headers(HeaderMap::from_iter([("X-Flipt-Environment".into(), "production".into())])).build());
Dependencies
~5–21MB
~221K SLoC