From 7da7f39085cfc84452680df984de04a4a702df85 Mon Sep 17 00:00:00 2001 From: Lewin Bormann Date: Sat, 4 Feb 2017 17:01:58 +0100 Subject: [PATCH] chore(deps): Move pubsub example to hyper 0.10. --- examples/service_account/Cargo.toml | 1 + examples/service_account/src/main.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/service_account/Cargo.toml b/examples/service_account/Cargo.toml index 75083b4..eccc144 100644 --- a/examples/service_account/Cargo.toml +++ b/examples/service_account/Cargo.toml @@ -12,3 +12,4 @@ base64 = "0.2" yup-oauth2 = "^ 1.0" google-pubsub1 = "^ 1.0" hyper = "0.10" +hyper-rustls = "^ 0.3" diff --git a/examples/service_account/src/main.rs b/examples/service_account/src/main.rs index bba305e..51f0cee 100644 --- a/examples/service_account/src/main.rs +++ b/examples/service_account/src/main.rs @@ -24,11 +24,13 @@ extern crate base64; extern crate yup_oauth2 as oauth; extern crate google_pubsub1 as pubsub; extern crate hyper; +extern crate hyper_rustls; use std::env; use std::time; use std::thread; +use hyper::net::HttpsConnector; use pubsub::{Topic, Subscription}; // The prefixes are important! @@ -158,13 +160,15 @@ fn publish_stuff(methods: &PubsubMethods, message: &str) { fn main() { let client_secret = oauth::service_account_key_from_file(&"pubsub-auth.json".to_string()) .unwrap(); - let mut access = oauth::ServiceAccountAccess::new(client_secret, hyper::Client::new()); + let client = hyper::Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new())); + let mut access = oauth::ServiceAccountAccess::new(client_secret, client); use oauth::GetToken; println!("{:?}", access.token(&vec!["https://www.googleapis.com/auth/pubsub"]).unwrap()); - let hub = pubsub::Pubsub::new(hyper::Client::new(), access); + let client = hyper::Client::with_connector(HttpsConnector::new(hyper_rustls::TlsClient::new())); + let hub = pubsub::Pubsub::new(client, access); let methods = hub.projects(); let mode = env::args().nth(1).unwrap_or(String::new());