Compare commits

...

2 Commits

Author SHA1 Message Date
six edeccdf9f4 http 2022-04-30 16:47:47 +02:00
six 4b8114e234 http 2022-04-30 16:47:36 +02:00
4 changed files with 28 additions and 3 deletions

View File

@ -0,0 +1,10 @@
// [dependencies]
// reqwest = "0.11"
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let resp = reqwest::blocking::get("https://api.coindesk.com/v1/bpi/currentprice.json")?.text()?;
println!("{:#?}", resp);
Ok(())
}

View File

@ -0,0 +1,10 @@
use http::{Request, Response};
fn main() {
let mut request = Request::builder();
request.uri("https://api.coindesk.com/v1/bpi/currentprice.json")
.header("User-Agent", "my-awesome-agent/1.0");
println!("{:#?}", request)
}

View File

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.11", features = ["blocking"] }

View File

@ -1,10 +1,11 @@
fn main() {
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
//// 000_println.rs
println!("Printed text.");
print!("No new line.");
//// 010_add_distract_math_literal_operator.rs
//https://doc.rust-lang.org/rust-by-example/primitives/literals.html
println!("1 + 2 = {}", 1u32 + 2);
@ -31,6 +32,10 @@ fn main() {
reverse((1,true));
tuplez();
// HTTP example
let body = reqwest::blocking::get("https://api.coindesk.com/v1/bpi/currentprice.json")?.text()?;
println!("body = {:?}", body);
Ok(())
}
@ -96,4 +101,3 @@ fn tuplez() {
println!("{:?}", matrix);
}