Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
🔊 Fix empty response from proxy
Browse files Browse the repository at this point in the history
Close #5
  • Loading branch information
TilBlechschmidt committed Mar 25, 2021
1 parent 895c3c3 commit b81f5f0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/src/services/proxy/jobs/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,21 @@ impl ProxyJob {
debug!("{} {} -> {}", req.method(), path, upstream);

*req.uri_mut() = format!("http://{}{}", upstream, path).parse().unwrap();
Ok(self.client.request(req).await?)

let result = self.client.request(req).await;

match result {
Ok(res) => Ok(res),
Err(e) => {
error!("Failed to fulfill request to '{}': {}", upstream, e);
let error_message = format!("Unable to forward request to {}: {}", upstream, e);

Ok(Response::builder()
.status(StatusCode::BAD_GATEWAY)
.body(error_message.into())
.unwrap())
}
}
}

async fn handle_session_request(
Expand Down

0 comments on commit b81f5f0

Please sign in to comment.