Skip to content

Instantly share code, notes, and snippets.

@flaper87
Created September 14, 2013 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaper87/6566222 to your computer and use it in GitHub Desktop.
Save flaper87/6566222 to your computer and use it in GitHub Desktop.
Build URLs with custom query params
extern mod extra;
use extra::url::Url;
fn main() {
let params = ~[(~"test", ~"value")];
let mut url: Url = FromStr::from_str("http://www.example.com").unwrap();
// url.query is extra::url::Query
// which is a type = ~[(~str, ~str)]
url.query.push_all(params);
// prints http://www.example.com?test=value
println(url.to_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment