failure mode handle

This commit is contained in:
Brandon Thomas
2020-08-06 01:51:15 -04:00
parent fe3321ef02
commit f25d3dbe9d
+9 -5
View File
@@ -10,6 +10,7 @@ use futures::future::{self, Future};
use futures::future::Map; use futures::future::Map;
use futures::future::MapErr; use futures::future::MapErr;
use hyper::client::Client; use hyper::client::Client;
use hyper::error::Error as HyperError;
use hyper::header::HeaderValue; use hyper::header::HeaderValue;
use hyper::http::header::HeaderName; use hyper::http::header::HeaderName;
use hyper::rt::Stream; use hyper::rt::Stream;
@@ -169,9 +170,10 @@ fn speak_proxy(
let client = Client::new(); let client = Client::new();
let fut = client let fut = client
.get(Uri::from_static("http://httpbin.org/ip")) //.get(Uri::from_static("http://httpbin.org/ip"))
.get(Uri::from_static("http://asdfahsfahshfajshdfasf.com/ip"))
.and_then(|res| { .and_then(|res| {
println!("status: {}", res.status()); info!("status: {}", res.status());
// Concatenate the body stream into a single buffer... // Concatenate the body stream into a single buffer...
// This returns a new future, since we must stream body. // This returns a new future, since we must stream body.
res.into_body().concat2() res.into_body().concat2()
@@ -191,10 +193,12 @@ fn speak_proxy(
Ok(r) Ok(r)
}) })
// Map any errors that might have happened... .or_else(|err| {
/*.map_err(|err| {
println!("error: {}", err); println!("error: {}", err);
})*/ let b = Body::from("test".to_string());
let r = Response::new(b);
Ok(r)
})
; ;