Skip to content

Instantly share code, notes, and snippets.

@rjloura
Last active March 29, 2019 23:37
Show Gist options
  • Save rjloura/6876d6e4da00b740159884d3f9d92ffd to your computer and use it in GitHub Desktop.
Save rjloura/6876d6e4da00b740159884d3f9d92ffd to your computer and use it in GitHub Desktop.
How to add get query params to hyper.rs URL
extern crate url;
extern create hyper;
use url::Url;
use hyper::{Client, Uri};
let mut url = Url::parse("http://api.openweathermap.org/data/2.5/weather").unwrap();
url.query_pairs_mut()
.append_pair("q", "some query")
.append_pair("p", "some other query);
let uri = url.as_str().parse::<Uri>().unwrap();
let client = Client::new();
client.get(uri)
.and_then()...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment