Created
September 14, 2013 22:18
-
-
Save flaper87/6566222 to your computer and use it in GitHub Desktop.
Build URLs with custom query params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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