This commit is contained in:
Brandon Thomas
2020-06-29 19:42:32 -04:00
parent 649623c39f
commit b268d98b86
+7 -16
View File
@@ -95,14 +95,6 @@ fn debug_request(req: Request<Body>) -> BoxFut {
Box::new(future::ok(response)) Box::new(future::ok(response))
} }
fn speak_request(req: Request<Body>, remote_addr: SocketAddr) -> BoxFut {
speak_proxy(req, remote_addr, "/speak")
}
fn speak_spectrogram_request(req: Request<Body>, remote_addr: SocketAddr) -> BoxFut {
speak_proxy(req, remote_addr, "/speak_spectrogram")
}
fn speak_proxy(req: Request<Body>, remote_addr: SocketAddr, endpoint: &'static str) -> BoxFut { fn speak_proxy(req: Request<Body>, remote_addr: SocketAddr, endpoint: &'static str) -> BoxFut {
let mut headers = req.headers().clone(); let mut headers = req.headers().clone();
// NB: Rehydrating the request payload can change the content length if whitespace is changed. // NB: Rehydrating the request payload can change the content length if whitespace is changed.
@@ -182,14 +174,13 @@ fn main() -> AnyhowResult<()> {
_ => {}, _ => {},
} }
let remote_addr2 = remote_addr.clone(); match req.uri().path() {
"/speak" =>
if req.uri().path().eq("/speak") { speak_proxy(req, remote_addr.clone(), "/speak"),
speak_request(req, remote_addr2) "/speak_spectrogram" =>
} else if req.uri().path().eq("/speak_spectrogram") { speak_proxy(req, remote_addr.clone(), "/speak_spectrogram"),
speak_spectrogram_request(req, remote_addr2) _ =>
} else { debug_request(req),
debug_request(req)
} }
}) })
}); });