aboutsummaryrefslogtreecommitdiff
path: root/examples/request_blocking.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/request_blocking.rs')
-rw-r--r--examples/request_blocking.rs33
1 files changed, 29 insertions, 4 deletions
diff --git a/examples/request_blocking.rs b/examples/request_blocking.rs
index fed1c41..8d6e513 100644
--- a/examples/request_blocking.rs
+++ b/examples/request_blocking.rs
@@ -16,11 +16,36 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+//! This example demonstrates Germ's capabilities for performing a blocking
+//! request to a Gemini capsule.
+
fn main() {
- match germ::request::blocking::request(
- &url::Url::parse("gemini://fuwn.me").unwrap(),
- ) {
- Ok(response) => println!("{:?}", response),
+ // Form a valid URL to a Gemini capsule
+ let url = url::Url::parse("gemini://fuwn.me").unwrap();
+ // Perform a blocking request to the Gemini capsule
+ let request = germ::request::blocking::request(&url);
+
+ 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(_) => {}
}
}