actix-webfinger/examples/fetch.rs

29 lines
776 B
Rust
Raw Normal View History

2019-05-12 17:19:49 +00:00
use actix::System;
use actix_web::client::Connector;
2019-01-27 20:45:44 +00:00
use actix_webfinger::Webfinger;
2019-05-12 17:19:49 +00:00
use futures::{future::lazy, Future};
2019-01-27 20:45:44 +00:00
use openssl::ssl::{SslConnector, SslMethod};
2019-05-12 17:19:49 +00:00
use std::error::Error;
2019-01-27 20:45:44 +00:00
2019-05-12 17:19:49 +00:00
fn main() -> Result<(), Box<dyn Error>> {
2019-01-27 20:45:44 +00:00
let sys = System::new("sir-boops");
2019-05-12 17:19:49 +00:00
let ssl_conn = SslConnector::builder(SslMethod::tls())?.build();
let conn = Connector::new().ssl(ssl_conn).finish();
2019-01-27 20:45:44 +00:00
2019-05-12 17:19:49 +00:00
let fut = lazy(move || {
Webfinger::fetch(conn, "asonix@asonix.dog", "localhost:8000", false)
.map(move |w: Webfinger| {
println!("asonix's webfinger:\n{:#?}", w);
2019-01-27 20:45:44 +00:00
2019-05-12 17:19:49 +00:00
System::current().stop();
})
.map_err(|e| eprintln!("Error: {}", e))
});
2019-01-27 20:45:44 +00:00
actix::spawn(fut);
2019-05-12 17:19:49 +00:00
sys.run()?;
Ok(())
2019-01-27 20:45:44 +00:00
}