mirror of
https://github.com/actix/examples
synced 2024-11-30 17:14:35 +01:00
fix proxy example
This commit is contained in:
parent
09b0188ff9
commit
bc2b17602e
@ -16,20 +16,11 @@ fn forward(
|
|||||||
new_url.set_query(req.uri().query());
|
new_url.set_query(req.uri().query());
|
||||||
|
|
||||||
let forwarded_req = client.request_from(new_url.as_str(), req.head());
|
let forwarded_req = client.request_from(new_url.as_str(), req.head());
|
||||||
|
let forwarded_req = if let Some(addr) = req.head().peer_addr {
|
||||||
// if let Some(addr) = req.peer_addr() {
|
forwarded_req.header("x-forwarded-for", format!("{}", addr.ip()))
|
||||||
// match forwarded_req.headers_mut().entry("x-forwarded-for") {
|
} else {
|
||||||
// Ok(http::header::Entry::Vacant(entry)) => {
|
forwarded_req
|
||||||
// let addr = format!("{}", addr.ip());
|
};
|
||||||
// entry.insert(addr.parse().unwrap());
|
|
||||||
// }
|
|
||||||
// Ok(http::header::Entry::Occupied(mut entry)) => {
|
|
||||||
// let addr = format!("{}, {}", entry.get().to_str().unwrap(), addr.ip());
|
|
||||||
// entry.insert(addr.parse().unwrap());
|
|
||||||
// }
|
|
||||||
// _ => unreachable!(),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
forwarded_req
|
forwarded_req
|
||||||
.send_stream(payload)
|
.send_stream(payload)
|
||||||
|
@ -19,5 +19,5 @@ yarte = { version = "0.2", features=["with-actix-web"] }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
actix-http-test = "0.1.0-alpha.3"
|
actix-http-test = "0.1.0"
|
||||||
actix-http = "0.1.0-alpha.4"
|
actix-http = "0.1.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user