diff options
| author | Fuwn <[email protected]> | 2024-03-25 00:59:25 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-03-25 00:59:25 +0000 |
| commit | 40680a3648cc7d598d428d6fe1752a2be9bfd547 (patch) | |
| tree | c4ea43de3543995c0b81e1a982c8671479012fd5 /examples/request_blocking.rs | |
| parent | feat(crate): bump version (diff) | |
| download | germ-40680a3648cc7d598d428d6fe1752a2be9bfd547.tar.xz germ-40680a3648cc7d598d428d6fe1752a2be9bfd547.zip | |
docs(examples): comment examples
Diffstat (limited to 'examples/request_blocking.rs')
| -rw-r--r-- | examples/request_blocking.rs | 33 |
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(_) => {} } } |