Skip to content

Commit b68a7bc

Browse files
authored
Titan's api_token from env var (#837)
## ✅ I have completed the following steps: * [X] Run `make lint` * [X] Run `make test` * [ ] Added tests (if applicable)
1 parent c07bef2 commit b68a7bc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/bid-scraper/src/titan_ws_publisher.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
};
66
use eyre::Context;
77
use futures::stream::{SplitSink, SplitStream};
8+
use rbuilder_config::EnvOrValue;
89
use serde::Deserialize;
910
use tokio::net::TcpStream;
1011
use tokio_tungstenite::{
@@ -19,7 +20,7 @@ pub struct TitanWsPublisherConfig {
1920
/// Be sure to use unique names. Maybe we can take it from the titan_url?
2021
pub relay_name: String,
2122
/// used as header X-Api-Token, for use with titan builder direct endpoint
22-
pub api_token: String,
23+
pub api_token: EnvOrValue<String>,
2324
}
2425

2526
pub struct TitanWsConnectionHandler {
@@ -39,9 +40,10 @@ impl ConnectionHandler for TitanWsConnectionHandler {
3940
}
4041
fn configure_request(&self, request: &mut Request<()>) -> eyre::Result<()> {
4142
let headers = request.headers_mut();
42-
let api_token_header_value =
43-
tokio_tungstenite::tungstenite::http::HeaderValue::from_str(&self.cfg.api_token)
44-
.wrap_err("Invalid header value for 'X-Api-Token'")?;
43+
let api_token_header_value = tokio_tungstenite::tungstenite::http::HeaderValue::from_str(
44+
&self.cfg.api_token.value()?,
45+
)
46+
.wrap_err("Invalid header value for 'X-Api-Token'")?;
4547
headers.insert("X-Api-Token", api_token_header_value);
4648
Ok(())
4749
}

0 commit comments

Comments
 (0)