Page MenuHomeDevCentral

No OneTemporary

diff --git a/ds-http-client/Cargo.toml b/ds-http-client/Cargo.toml
index 1d3e35e..0f49910 100644
--- a/ds-http-client/Cargo.toml
+++ b/ds-http-client/Cargo.toml
@@ -1,15 +1,20 @@
[package]
name = "ds-http-client"
version = "0.1.0"
edition = "2021"
+description = "HTTP client to download files or query API with User-Agent set"
+authors = [
+ "Sébastien Santoro <dereckson@espace-win.org>"
+]
+license = "BSD-2-Clause"
[dependencies]
lazy_static = "~1.5.0"
[dependencies.reqwest]
version = "~0.12.7"
features = ["gzip", "deflate"]
[dependencies.tokio]
version = "~1.39.3"
features = ["full"]
diff --git a/ds-http-client/README.md b/ds-http-client/README.md
new file mode 100644
index 0000000..02c549c
--- /dev/null
+++ b/ds-http-client/README.md
@@ -0,0 +1,34 @@
+# HTTP client for Nasqueron Datasources components
+
+The crate ds-http-client is a HTTP client
+based on Hyper / reqwest components.
+
+It can be used to download a file on an HTTP server,
+or query an API with User-Agent header.
+
+## Usage example
+
+### Initialize a client
+
+ ```
+ use ds_http_client::Client;
+
+ let mut headers = HashMap::new();
+ headers.insert(
+ "User-Agent".to_string(),
+ "foo/1.2.3".to_string(),
+ );
+
+ let client = Client::new(Some(headers));
+ ```
+
+### Download a file
+
+ ```
+ let url = "http://www.example.com/example.tar.gz";
+ let target_path = "/tmp/example.tar.gz";
+
+ if let Err(error) = client().download(&url, &target_path).await {
+ eprintln!("Can't download file: {:?}", error);
+ }
+ ```

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 18:15 (1 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258628
Default Alt Text
(1 KB)

Event Timeline