Skip to content

Commit

Permalink
fix(examples): use hyper-native-tls for TLS
Browse files Browse the repository at this point in the history
Modify examples to use the `hyper-native-tls` TLS connector to provide TLS
support to Hyper. This is necessary as of Hyper 0.10.

Closes #18.
  • Loading branch information
indiv0 committed Feb 17, 2017
1 parent adc03ae commit d342be5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ version = "0.0"
optional = true
version = "0.10.4"

[dev_dependencies]
hyper-native-tls = "0.2.2"

[features]
default = ["hyper"]
nightly-testing = ["clippy"]
9 changes: 8 additions & 1 deletion examples/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
// except according to those terms.

extern crate hyper;
extern crate hyper_native_tls;
extern crate xkcd;

use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;

fn main() {
let client = hyper::Client::new();
let tls = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(tls);
let client = Client::with_connector(connector);

// Retrieve the latest comic ID.
let latest_id = xkcd::comics::latest(&client).unwrap().num;
Expand Down
9 changes: 8 additions & 1 deletion examples/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
// except according to those terms.

extern crate hyper;
extern crate hyper_native_tls;
extern crate xkcd;

use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;

fn main() {
let client = hyper::Client::new();
let tls = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(tls);
let client = Client::with_connector(connector);

// Retrieve the latest comic.
let latest_comic = xkcd::comics::latest(&client);
Expand Down
9 changes: 8 additions & 1 deletion examples/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
// except according to those terms.

extern crate hyper;
extern crate hyper_native_tls;
extern crate xkcd;

use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;

fn main() {
let client = hyper::Client::new();
let tls = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(tls);
let client = Client::with_connector(connector);

// Retrieve a random comic.
let random_comic = xkcd::random::random(&client);
Expand Down

0 comments on commit d342be5

Please sign in to comment.