parent
a86020eedf
commit
4a2ac7460f
@ -0,0 +1,21 @@ |
||||
use crate::error::unexpected; |
||||
use std::net; |
||||
|
||||
// proxy is a special case because it is so tied to the underlying protocol that a request is
|
||||
// being served on, it can't be abstracted out into a simple "get_file" operation like other
|
||||
// origins.
|
||||
|
||||
pub async fn serve_http_request( |
||||
client_ip: net::IpAddr, |
||||
proxy_url: &str, |
||||
req: hyper::Request<hyper::Body>, |
||||
) -> unexpected::Result<hyper::Response<hyper::Body>> { |
||||
match hyper_reverse_proxy::call(client_ip, proxy_url, req).await { |
||||
Ok(res) => Ok(res), |
||||
// ProxyError doesn't actually implement Error :facepalm: so we have to format the error
|
||||
// manually
|
||||
Err(e) => Err(unexpected::Error::from( |
||||
format!("error while proxying: {e:?}").as_str(), |
||||
)), |
||||
} |
||||
} |
Loading…
Reference in new issue