aboutsummaryrefslogtreecommitdiff
path: root/examples/http_fail.rs
blob: 98e027a05395be98f5fe3a77ababdbbddbd457cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use eyre::Result;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Author {
    pub id: i32,
    pub name: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Comment {
    pub id: i32,
    pub author: Author,
    pub body: String,
    pub in_reply_to: i32,
}

#[tokio::main]
async fn main() -> Result<()> {
    let c: Comment = reqwest::get("https://xena.greedo.xeserv.us/files/comment2.json")
        .await?
        .error_for_status()?
        .json()
        .await?;
    println!("comment: {:#?}", c);

    Ok(())
}