add proxy healthcheck endpoint

This commit is contained in:
Brandon Thomas
2020-06-30 06:51:35 -04:00
parent 801304adde
commit ae060729dc
+7
View File
@@ -97,6 +97,11 @@ fn _debug_request(req: Request<Body>) -> BoxFut {
Box::new(future::ok(response))
}
fn health_check_response(_req: Request<Body>) -> BoxFut {
let response = Response::new(Body::from("healthy"));
Box::new(future::ok(response))
}
struct RequestDetails {
pub request_bytes: Vec<u8>,
pub speaker: String,
@@ -227,6 +232,8 @@ fn main() -> AnyhowResult<()> {
speak_proxy(req, remote_addr.clone(), router3, "/speak"),
(&Method::POST, "/speak_spectrogram") =>
speak_proxy(req, remote_addr.clone(), router3, "/speak_spectrogram"),
(&Method::GET, "/proxy_health") =>
health_check_response(req),
_ => {
let forward = router3.get_random_host();
info!("Forwarding to `{}` random host: {}", &forward, req.uri());