aboutsummaryrefslogtreecommitdiff
path: root/examples/request.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-03-25 00:59:25 +0000
committerFuwn <[email protected]>2024-03-25 00:59:25 +0000
commit40680a3648cc7d598d428d6fe1752a2be9bfd547 (patch)
treec4ea43de3543995c0b81e1a982c8671479012fd5 /examples/request.rs
parentfeat(crate): bump version (diff)
downloadgerm-40680a3648cc7d598d428d6fe1752a2be9bfd547.tar.xz
germ-40680a3648cc7d598d428d6fe1752a2be9bfd547.zip
docs(examples): comment examples
Diffstat (limited to 'examples/request.rs')
-rw-r--r--examples/request.rs33
1 files changed, 29 insertions, 4 deletions
diff --git a/examples/request.rs b/examples/request.rs
index 33de2da..bb565c1 100644
--- a/examples/request.rs
+++ b/examples/request.rs
@@ -16,12 +16,37 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+//! This example demonstrates Germ's capabilities for performing a non-blocking
+//! request to a Gemini capsule.
+
#[tokio::main]
async fn main() {
- match germ::request::request(&url::Url::parse("gemini://fuwn.me").unwrap())
- .await
- {
- Ok(response) => println!("{:?}", response),
+ // Form a valid URL to a Gemini capsule
+ let url = url::Url::parse("gemini://fuwn.me").unwrap();
+ // Perform a non-blocking request to the Gemini capsule
+ let request = germ::request::request(&url).await;
+
+ match request {
+ // If the request was successful, print a debug view of the response
+ Ok(response) => {
+ // Print the status of the response
+ println!("{:?}", response.status());
+
+ // Print the meta string of the response
+ //
+ // More detailed meta usage can be found in the `meta` example
+ println!("{}", response.meta());
+
+ // Print the content of the response, if present
+ println!("{:?}", response.content());
+
+ // Print the size of the response
+ println!("{:?}", response.size());
+
+ // Print a debug view of the SSL suite used
+ println!("{:?}", response.suite());
+ }
+ // If the request was unsuccessful, do nothing
Err(_) => {}
}
}