mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-19 07:43:12 +00:00
cleanup default routing
This commit is contained in:
+5
-15
@@ -97,7 +97,6 @@ fn debug_request(req: Request<Body>) -> BoxFut {
|
|||||||
Box::new(future::ok(response))
|
Box::new(future::ok(response))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct RequestDetails {
|
struct RequestDetails {
|
||||||
pub request_bytes: Vec<u8>,
|
pub request_bytes: Vec<u8>,
|
||||||
pub speaker: String,
|
pub speaker: String,
|
||||||
@@ -168,24 +167,15 @@ fn main() -> AnyhowResult<()> {
|
|||||||
info!("Got a request from: {:?}", remote_addr);
|
info!("Got a request from: {:?}", remote_addr);
|
||||||
|
|
||||||
let route_a = route_one.clone();
|
let route_a = route_one.clone();
|
||||||
let route_b = route_two.clone();
|
|
||||||
|
|
||||||
service_fn(move |req: Request<Body>| { // returns BoxFut
|
service_fn(move |req: Request<Body>| {
|
||||||
match req.method() {
|
match (req.method(), req.uri().path()) {
|
||||||
&Method::OPTIONS => {
|
(&Method::POST, "/speak") =>
|
||||||
// TODO: CORS should be hardcoded here, not wastefully proxied.
|
|
||||||
return hyper_reverse_proxy::call(remote_addr.ip(), &route_a, req); // Return BoxFut
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
match req.uri().path() {
|
|
||||||
"/speak" =>
|
|
||||||
speak_proxy(req, remote_addr.clone(), "/speak"),
|
speak_proxy(req, remote_addr.clone(), "/speak"),
|
||||||
"/speak_spectrogram" =>
|
(&Method::POST, "/speak_spectrogram") =>
|
||||||
speak_proxy(req, remote_addr.clone(), "/speak_spectrogram"),
|
speak_proxy(req, remote_addr.clone(), "/speak_spectrogram"),
|
||||||
_ =>
|
_ =>
|
||||||
debug_request(req),
|
hyper_reverse_proxy::call(remote_addr.ip(), &route_a, req),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user