Skip to main content

run_server_with

Function run_server_with 

Source
pub async fn run_server_with(
    redis_url: &str,
    graph: &str,
    registry: Arc<SchemaRegistry>,
    addr: SocketAddr,
    options: ServerOptions,
) -> Result<()>
Expand description

run_server with TLS and/or header authentication.

This example pairs mutual TLS (transport identity) with Basic + bearer header auth (application identity) — the belt-and-suspenders setup a Power BI / ADBC client on Windows connects to.

use std::sync::Arc;
use graphar_flight::{SchemaRegistry, run_server_with, ServerOptions, TlsOptions};

#[tokio::main]
async fn main() {
    let opts = ServerOptions {
        tls: Some(
            TlsOptions::mutual_from_pem_files("server.crt", "server.key", "client-ca.crt")
                .unwrap(),
        ),
        bearer_token: Some("s3cret".into()),
        basic_auth: Some(("analyst".into(), "p@ss".into())),
        ..Default::default()
    };
    run_server_with(
        "redis://127.0.0.1:6379",
        "mygraph",
        Arc::new(SchemaRegistry::new()),
        "0.0.0.0:50051".parse().unwrap(),
        opts,
    ).await.unwrap();
}