raxios

Crates.ioraxios
lib.rsraxios
version0.5.2
sourcesrc
created_at2022-09-20 00:02:08.626337
updated_at2022-10-01 20:29:43.232488
descriptionAn easy to use HTTP client for Rust based off of JS Axios library
homepage
repositoryhttps://github.com/dbidwell94/raxios
max_upload_size
id669454
size48,460
Devin Bidwell (dbidwell94)

documentation

README

Raxios

Async-centered Rust library similar to the JS library "axios"

!DISCLAIMER! While Raxios is in an alpha state, consider any minor version changes to be breaking changes. Raxios will not be out of Alpha state and stable until the 1.0.0 release.

Features

  • JSON, XML, and URL-Encoded Serialization

  • JSON Deserialization (XML and others to come)

  • An "axios"-like api

Usage/Examples

use raxios::Raxios;

#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct ToReceive {
    field1: String
}

#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct ToSend {
    field1: String
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {

    // An error _might_ occur here if you try to set non-valid headers in the Options
    let client = Raxios::new("", None)?;

    let data_to_send = ToSend { field1 : String::from("Hello World") };

    let result = client
        .post::<ToReceive, ToSend>("/endpoint", Some(data_to_send), None)
        .await?;

    println!("{0}", result.body.unwrap());
}

Documentation

docs.rs

License

MIT

docs.rs downloads Version
docs.rs Crates.io Crates.io
Commit count: 40

cargo fmt