mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +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());
|
||||
|
||||
let forwarded_req = client.request_from(new_url.as_str(), req.head());
|
||||
|
||||
// if let Some(addr) = req.peer_addr() {
|
||||
// match forwarded_req.headers_mut().entry("x-forwarded-for") {
|
||||
// Ok(http::header::Entry::Vacant(entry)) => {
|
||||
// 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!(),
|
||||
// }
|
||||
// }
|
||||
let forwarded_req = if let Some(addr) = req.head().peer_addr {
|
||||
forwarded_req.header("x-forwarded-for", format!("{}", addr.ip()))
|
||||
} else {
|
||||
forwarded_req
|
||||
};
|
||||
|
||||
forwarded_req
|
||||
.send_stream(payload)
|
||||
|
@ -19,5 +19,5 @@ yarte = { version = "0.2", features=["with-actix-web"] }
|
||||
|
||||
[dev-dependencies]
|
||||
bytes = "0.4"
|
||||
actix-http-test = "0.1.0-alpha.3"
|
||||
actix-http = "0.1.0-alpha.4"
|
||||
actix-http-test = "0.1.0"
|
||||
actix-http = "0.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user