summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples/replace_config.rs
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@gmail.com>2018-06-27 18:38:51 -0400
committerGitHub <noreply@github.com>2018-06-27 18:38:51 -0400
commit8ddbbd1854f86a15d522247993e6c6ce39db1781 (patch)
tree82b60aa1968a3e685b08e685efaa24ecaa99f768 /ipfs-api/examples/replace_config.rs
parentbbaa488b09cf6b77416a65f8cae6da2aafeb88d5 (diff)
parentfedf875de04c8577a439bff9f62f1cb7d079459a (diff)
Merge pull request #16 from ferristseng/upgrade-hyper
Upgrade hyper to 0.12.0
Diffstat (limited to 'ipfs-api/examples/replace_config.rs')
-rw-r--r--ipfs-api/examples/replace_config.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/ipfs-api/examples/replace_config.rs b/ipfs-api/examples/replace_config.rs
index e66c920..f354386 100644
--- a/ipfs-api/examples/replace_config.rs
+++ b/ipfs-api/examples/replace_config.rs
@@ -6,12 +6,13 @@
// copied, modified, or distributed except according to those terms.
//
+extern crate futures;
+extern crate hyper;
extern crate ipfs_api;
-extern crate tokio_core;
+use futures::Future;
use ipfs_api::IpfsClient;
use std::io::Cursor;
-use tokio_core::reactor::Core;
// Creates an Ipfs client, and replaces the config file with the default one.
//
@@ -19,12 +20,12 @@ fn main() {
println!("note: this must be run in the root of the project repository");
println!("connecting to localhost:5001...");
- let mut core = Core::new().expect("expected event loop");
- let client = IpfsClient::default(&core.handle());
+ let client = IpfsClient::default();
let default_config = include_str!("default_config.json");
- let req = client.config_replace(Cursor::new(default_config));
+ let req = client
+ .config_replace(Cursor::new(default_config))
+ .map(|_| println!("replaced file"))
+ .map_err(|e| println!("{}", e));
- core.run(req).expect("expected a valid response");
-
- println!("replaced file");
+ hyper::rt::run(req);
}