summaryrefslogtreecommitdiffstats
path: root/ipfs-api/examples/get_swarm.rs
diff options
context:
space:
mode:
authorFerris Tseng <ferristseng@gmail.com>2019-02-13 20:38:01 -0500
committerGitHub <noreply@github.com>2019-02-13 20:38:01 -0500
commitde3588c7c369ea4f4cca66f89c12511d1170e5f5 (patch)
tree965a5a80b387c0eb719ca568a96a729d9d3f2ade /ipfs-api/examples/get_swarm.rs
parentf125fdbde329095419630e02ebf33d2c73aeced7 (diff)
parent4bdebbf4d1d1edb839eba860b013e3fdb870f66e (diff)
Merge pull request #28 from ferristseng/actix
Add actix feature for using actix-web
Diffstat (limited to 'ipfs-api/examples/get_swarm.rs')
-rw-r--r--ipfs-api/examples/get_swarm.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/ipfs-api/examples/get_swarm.rs b/ipfs-api/examples/get_swarm.rs
index 2b9fd73..2b2c238 100644
--- a/ipfs-api/examples/get_swarm.rs
+++ b/ipfs-api/examples/get_swarm.rs
@@ -6,7 +6,10 @@
// copied, modified, or distributed except according to those terms.
//
+#[cfg(feature = "actix")]
+extern crate actix_web;
extern crate futures;
+#[cfg(feature = "hyper")]
extern crate hyper;
extern crate ipfs_api;
@@ -43,9 +46,17 @@ fn main() {
}
});
- hyper::rt::run(
- local
- .and_then(|_| connected)
- .map_err(|e| eprintln!("{}", e)),
- );
+ let fut = local
+ .and_then(|_| connected)
+ .map_err(|e| eprintln!("{}", e));
+
+ #[cfg(feature = "hyper")]
+ hyper::rt::run(fut);
+ #[cfg(feature = "actix")]
+ actix_web::actix::run(|| {
+ fut.then(|_| {
+ actix_web::actix::System::current().stop();
+ Ok(())
+ })
+ });
}