aboutsummaryrefslogtreecommitdiff
path: root/examples/http.rs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2020-09-27 12:35:24 -0400
committerGitHub <noreply@github.com>2020-09-27 12:35:24 -0400
commitf106c2c9d23c9c12a88b5a73f704f4be5c455926 (patch)
tree6b3888c1bcf2f8c379acbc897bab7f3fa7b9c8ca /examples/http.rs
parente460ebdcbee67224a3f9872b0a59e6f2733b6861 (diff)
downloadxesite-f106c2c9d23c9c12a88b5a73f704f4be5c455926.tar.xz
xesite-f106c2c9d23c9c12a88b5a73f704f4be5c455926.zip
go-stdlib-rust post (#215)
Diffstat (limited to 'examples/http.rs')
-rw-r--r--examples/http.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/http.rs b/examples/http.rs
new file mode 100644
index 0000000..c1533a6
--- /dev/null
+++ b/examples/http.rs
@@ -0,0 +1,27 @@
+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/comment.json")
+ .await?
+ .json()
+ .await?;
+ println!("comment: {:#?}", c);
+
+ Ok(())
+}