diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-10-21 15:41:02 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-10-30 23:15:25 +0100 |
| commit | 686ba55b08b623b0c7280ed0394bb10f29172fbf (patch) | |
| tree | 7115f9850d76cf48a3e41460a3f176d9113afb1f /mullvad-api/src | |
| parent | d0908106ee985700e9b0cf473e885214d4b3c404 (diff) | |
| download | mullvadvpn-686ba55b08b623b0c7280ed0394bb10f29172fbf.tar.xz mullvadvpn-686ba55b08b623b0c7280ed0394bb10f29172fbf.zip | |
Share hostname string in RequestFactory
Diffstat (limited to 'mullvad-api/src')
| -rw-r--r-- | mullvad-api/src/access.rs | 2 | ||||
| -rw-r--r-- | mullvad-api/src/lib.rs | 2 | ||||
| -rw-r--r-- | mullvad-api/src/rest.rs | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/mullvad-api/src/access.rs b/mullvad-api/src/access.rs index 2c244d1513..276cc1f561 100644 --- a/mullvad-api/src/access.rs +++ b/mullvad-api/src/access.rs @@ -38,7 +38,7 @@ struct AccountState { impl AccessTokenStore { pub(crate) fn new(service: RequestServiceHandle) -> Self { - let factory = rest::RequestFactory::new(API.host.clone(), None); + let factory = rest::RequestFactory::new(&API.host, None); let (tx, rx) = mpsc::unbounded(); tokio::spawn(Self::service_requests(rx, service, factory)); Self { tx } diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index 6d9a91b4ae..91e2bc524a 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -341,7 +341,7 @@ impl Runtime { ) .await; let token_store = access::AccessTokenStore::new(service.clone()); - let factory = rest::RequestFactory::new(API.host.clone(), Some(token_store)); + let factory = rest::RequestFactory::new(&API.host, Some(token_store)); rest::MullvadRestHandle::new( service, diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs index 8f4ec39731..f300b191e7 100644 --- a/mullvad-api/src/rest.rs +++ b/mullvad-api/src/rest.rs @@ -481,13 +481,13 @@ struct NewErrorResponse { #[derive(Clone)] pub struct RequestFactory { - hostname: String, + hostname: &'static str, token_store: Option<AccessTokenStore>, default_timeout: Duration, } impl RequestFactory { - pub fn new(hostname: String, token_store: Option<AccessTokenStore>) -> Self { + pub fn new(hostname: &'static str, token_store: Option<AccessTokenStore>) -> Self { Self { hostname, token_store, @@ -564,7 +564,7 @@ impl RequestFactory { .uri(uri) .header(header::USER_AGENT, HeaderValue::from_static(USER_AGENT)) .header(header::ACCEPT, HeaderValue::from_static("application/json")) - .header(header::HOST, self.hostname.clone()); + .header(header::HOST, HeaderValue::from_static(self.hostname)); let result = request.body(hyper::Body::empty())?; Ok(result) |
