Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

h1

Manav Rathi8c5c066329cc
diff --git a/rust/core/src/http.rs b/rust/core/src/http.rs
new file mode 100644
index 0000000000..7e7bac5567
--- /dev/null
+++ b/rust/core/src/http.rs
@@ -0,0 +1,47 @@
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+pub enum Error {
+ #[error("HTTP request failed: {0}")]
+ Request(#[from] reqwest::Error),
+}
+
+// TODO: Future HTTP features to implement:
+// - POST/PUT/DELETE methods
+// - JSON request bodies
+// - Streaming uploads/downloads
+// - Custom headers / auth tokens
+// - Retry logic
+// - Configurable timeouts
+
+pub struct HttpClient {
+ client: reqwest::Client,
+ base_url: String,
+}
+
+impl HttpClient {
+ pub fn new(base_url: &str) -> Self {
+ Self {
+ client: reqwest::Client::new(),
+ base_url: base_url.to_string(),
+ }
+ }
+
+ pub async fn get(&self, path: &str) -> Result<String, Error> {
+ let url = format!("{}{}", self.base_url, path);
+ let response = self.client.get(&url).send().await?;
+ let text = response.text().await?;
+ Ok(text)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_client_creation() {
+ let client = HttpClient::new("https://api.ente.io");
+ assert_eq!(client.base_url, "https://api.ente.io");
+ }
+}
diff --git a/rust/core/src/lib.rs b/rust/core/src/lib.rs
index c8faf421d7..57e037cc25 100644
--- a/rust/core/src/lib.rs
+++ b/rust/core/src/lib.rs
@@ -1 +1,2 @@
+pub mod http;
pub mod urls;