Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir and Gleam, Reading, and Design. She/Her. Constellation Webring Published on

Rust Crate - surf

Notes on surf

Snippets

  • Basic post requestUsing surf-2.3.2, tokio-1.33.0, serde-1.0.189.
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize)]
struct Ip {
    message: String,
    datetime: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let uri = "http://localhost:4000/api/notification";
    let data = &Ip {
        message: "test".into(),
        datetime: "2023-10-14T16:55:15".into(),
    };
    let _ = surf::post(uri).body_json(data)?.await?;
    Ok(())
}

Constellation Webring