mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-19 07:43:12 +00:00
still trying to get retry to work (broken)
This commit is contained in:
+14
-7
@@ -144,6 +144,7 @@ fn speak_proxy(
|
|||||||
transaction: MaybeNewRelicTransaction,
|
transaction: MaybeNewRelicTransaction,
|
||||||
endpoint: &'static str) -> BoxFut
|
endpoint: &'static str) -> BoxFut
|
||||||
{
|
{
|
||||||
|
info!("speak_proxy()");
|
||||||
let mut headers = req.headers().clone();
|
let mut headers = req.headers().clone();
|
||||||
|
|
||||||
// This is the IP of the Digital Ocean load balancer.
|
// This is the IP of the Digital Ocean load balancer.
|
||||||
@@ -170,15 +171,22 @@ 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_cstatic("http://httpbin.org/ip"))
|
||||||
.get(Uri::from_static("http://asdfahsfahshfajshdfasf.com/ip"))
|
.get(Uri::from_static("http://brand.io/404notexit"))
|
||||||
.and_then(|res| {
|
.then(|res| {
|
||||||
info!("status: {}", res.status());
|
let body = res.into_body();
|
||||||
|
let status_code = res.status();
|
||||||
|
|
||||||
|
let inner = body.concat2();
|
||||||
|
if status_code.is_success() {
|
||||||
// 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()
|
future::err(inner)
|
||||||
|
} else {
|
||||||
|
future::ok(inner)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.and_then(|body| {
|
.then(|body| {
|
||||||
// The body is just bytes, but let's print a string...
|
// The body is just bytes, but let's print a string...
|
||||||
let s = ::std::str::from_utf8(&body)
|
let s = ::std::str::from_utf8(&body)
|
||||||
.expect("httpbin sends utf-8 JSON")
|
.expect("httpbin sends utf-8 JSON")
|
||||||
@@ -192,7 +200,6 @@ fn speak_proxy(
|
|||||||
// out that Result is a Future that is ready immediately.
|
// out that Result is a Future that is ready immediately.
|
||||||
Ok(r)
|
Ok(r)
|
||||||
})
|
})
|
||||||
|
|
||||||
.or_else(|err| {
|
.or_else(|err| {
|
||||||
println!("error: {}", err);
|
println!("error: {}", err);
|
||||||
let b = Body::from("test".to_string());
|
let b = Body::from("test".to_string());
|
||||||
|
|||||||
Reference in New Issue
Block a user