mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-20 07:44:42 +00:00
failure mode handle
This commit is contained in:
+9
-5
@@ -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)
|
||||||
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user