Compare commits
2 Commits
6613d566e7
...
edeccdf9f4
Author | SHA1 | Date |
---|---|---|
six | edeccdf9f4 | |
six | 4b8114e234 |
|
@ -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(())
|
||||||
|
}
|
|
@ -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)
|
||||||
|
}
|
||||||
|
|
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["blocking"] }
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
fn main() {
|
use std::error::Error;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
//// 000_println.rs
|
//// 000_println.rs
|
||||||
println!("Printed text.");
|
println!("Printed text.");
|
||||||
print!("No new line.");
|
print!("No new line.");
|
||||||
|
|
||||||
|
|
||||||
//// 010_add_distract_math_literal_operator.rs
|
//// 010_add_distract_math_literal_operator.rs
|
||||||
//https://doc.rust-lang.org/rust-by-example/primitives/literals.html
|
//https://doc.rust-lang.org/rust-by-example/primitives/literals.html
|
||||||
println!("1 + 2 = {}", 1u32 + 2);
|
println!("1 + 2 = {}", 1u32 + 2);
|
||||||
|
@ -31,6 +32,10 @@ fn main() {
|
||||||
reverse((1,true));
|
reverse((1,true));
|
||||||
tuplez();
|
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);
|
println!("{:?}", matrix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue