summaryrefslogtreecommitdiffhomepage
path: root/mullvad-api
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-api')
-rw-r--r--mullvad-api/src/lib.rs12
-rw-r--r--mullvad-api/src/rest.rs4
2 files changed, 16 insertions, 0 deletions
diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs
index c0024b22ee..c8765ec2b2 100644
--- a/mullvad-api/src/lib.rs
+++ b/mullvad-api/src/lib.rs
@@ -620,4 +620,16 @@ impl ApiProxy {
let response = self.handle.service.request(request).await?;
response.deserialize().await
}
+
+ /// Check the availablility of `{APP_URL_PREFIX}/api-addrs`.
+ pub async fn api_addrs_available(&self) -> Result<bool, rest::Error> {
+ let request = self
+ .handle
+ .factory
+ .head(&format!("{APP_URL_PREFIX}/api-addrs"))?
+ .expected_status(&[StatusCode::OK]);
+
+ let response = self.handle.service.request(request).await?;
+ Ok(response.status().is_success())
+ }
}
diff --git a/mullvad-api/src/rest.rs b/mullvad-api/src/rest.rs
index 2484bec64b..559ddd4b4e 100644
--- a/mullvad-api/src/rest.rs
+++ b/mullvad-api/src/rest.rs
@@ -524,6 +524,10 @@ impl RequestFactory {
self.request(path, Method::DELETE)
}
+ pub fn head(&self, path: &str) -> Result<Request> {
+ self.request(path, Method::HEAD)
+ }
+
pub fn post_json<S: serde::Serialize>(&self, path: &str, body: &S) -> Result<Request> {
self.json_request(Method::POST, path, body)
}