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

Download history 144/week @ 2025-09-02 84/week @ 2025-09-09 63/week @ 2025-09-16 87/week @ 2025-09-23 48/week @ 2025-09-30 56/week @ 2025-10-07 363/week @ 2025-10-14 67/week @ 2025-10-21 69/week @ 2025-10-28 51/week @ 2025-11-04 53/week @ 2025-11-11 88/week @ 2025-11-18 98/week @ 2025-11-25 189/week @ 2025-12-02 175/week @ 2025-12-09 2/week @ 2025-12-16

472 downloads per month

MIT license

18KB
483 lines

Flipt Rust

crates.io

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