diff --git a/src/bin/relay.rs b/src/bin/relay.rs index d350249..764e4f1 100644 --- a/src/bin/relay.rs +++ b/src/bin/relay.rs @@ -95,7 +95,7 @@ async fn handle_http_response ( { println! ("Step 6"); let (parts, body) = req.into_parts (); - let resp_parts: http_serde::ResponseParts = rmp_serde::from_read_ref (&base64::decode (parts.headers.get ("X-PTTH-2LJYXWC4").unwrap ()).unwrap ()).unwrap (); + let resp_parts: http_serde::ResponseParts = rmp_serde::from_read_ref (&base64::decode (parts.headers.get (ptth::PTTH_MAGIC_HEADER).unwrap ()).unwrap ()).unwrap (); { let mut watchers = state.watchers.lock ().await; diff --git a/src/bin/server.rs b/src/bin/server.rs index 4694070..6a23999 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -14,7 +14,8 @@ use tokio::{ use ptth::http_serde; -const SERVER_URL: &str = "http://127.0.0.1:4000"; +const RELAY_URL: &str = "http://127.0.0.1:4000"; +const SERVER_NAME: &str = "alien_wildlands"; async fn handle_req_resp ( client: &Client, @@ -39,8 +40,8 @@ async fn handle_req_resp ( let response = ptth::file_server::serve_all (parts).await; let mut resp_req = client - .post (&format! ("{}/http_response/{}", SERVER_URL, req_id)) - .header ("X-PTTH-2LJYXWC4", base64::encode (rmp_serde::to_vec (&response.parts).unwrap ())); + .post (&format! ("{}/http_response/{}", RELAY_URL, req_id)) + .header (ptth::PTTH_MAGIC_HEADER, base64::encode (rmp_serde::to_vec (&response.parts).unwrap ())); if let Some (body) = response.body { resp_req = resp_req.body (body); @@ -65,7 +66,7 @@ async fn main () -> Result <(), Box > { delay_for (Duration::from_millis (backoff_delay)).await; } - let req_req = client.get ("http://127.0.0.1:4000/http_listen/alien_wildlands"); + let req_req = client.get (&format! ("{}/http_listen/{}", RELAY_URL, SERVER_NAME)); let req_resp = match req_req.send ().await { Err (e) => { diff --git a/src/lib.rs b/src/lib.rs index 8205e3e..f130975 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ pub mod file_server; pub mod http_serde; pub mod watcher; + +pub const PTTH_MAGIC_HEADER: &str = "X-PTTH-2LJYXWC4";