nfo

Rust Client

Rust HTTP client for the nfo centralized logging service using reqwest.

What it shows

Prerequisites

Start the HTTP service first:

python examples/http-service/main.py

Run

cd examples/rust-client
# Add to Cargo.toml: reqwest, serde, serde_json, tokio
cargo run

Key code

#[derive(Serialize)]
struct LogEntry<'a> {
    cmd: &'a str,
    args: Vec<&'a str>,
    language: &'a str,
}

pub async fn nfo_log(cmd: &str, args: Vec<&str>) {
    let client = Client::new();
    let entry = LogEntry { cmd, args, language: "rust" };
    let _ = client.post(&format!("{}/log", nfo_url()))
                  .json(&entry)
                  .send()
                  .await;
}