aboutsummaryrefslogtreecommitdiff
path: root/examples/request.rs
diff options
context:
space:
mode:
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(_) => {}
}
}