ayun-http 0.24.0

The RUST Framework for Web Rustceans.
Documentation
use crate::{error::Error, Http, HttpResult};
use ayun_core::{support::Container, traits::ErrorTrait, Result};

fn setup() -> Result<()> {
    let mut container = Container::default();

    container.register::<ayun_config::Config>()?;
    container.register::<Http>()?;

    Ok(container.boot()?)
}

#[tokio::test]
async fn reqwest() -> HttpResult<()> {
    let text = reqwest::get("https://www.rust-lang.org")
        .await?
        .text()
        .await?;

    assert!(text.contains("Rust"));

    Ok(())
}

#[tokio::test]
async fn get() -> HttpResult<()> {
    use ayun_core::support::app;

    setup()?;

    let http = app().resolve::<Http>().map_err(Error::wrap)?;

    let text = http
        .get("https://www.rust-lang.org")
        .send()
        .await?
        .text()
        .await?;

    assert!(text.contains("Rust"));

    Ok(())
}