| Crates.io | urlencoded |
| lib.rs | urlencoded |
| version | 0.6.0 |
| created_at | 2015-03-09 23:50:08.6759+00 |
| updated_at | 2017-11-22 18:55:44.266542+00 |
| description | Decoding middleware for url-encoded data. For use with Iron. |
| homepage | |
| repository | https://github.com/iron/urlencoded |
| max_upload_size | |
| id | 1547 |
| size | 11,651 |

URL Encoded middleware for the Iron web framework. Decode URL Encoded data from GET request queries and POST request bodies.
This example shows how to use urlencoded to parse GET request parameters.
extern crate iron;
extern crate urlencoded;
use iron::prelude::*;
use iron::status;
use urlencoded::UrlEncodedQuery;
fn log_params(req: &mut Request) -> IronResult<Response> {
// Extract the decoded data as hashmap, using the UrlEncodedQuery plugin.
match req.get_ref::<UrlEncodedQuery>() {
Ok(ref hashmap) => println!("Parsed GET request query string:\n {:?}", hashmap),
Err(ref e) => println!("{:?}", e)
};
Ok(Response::with((status::Ok, "Hello!")))
}
// Test out the server with `curl -i "http://localhost:3000/?name=franklin&name=trevor"`
fn main() {
Iron::new(log_params).http("127.0.0.1:3000").unwrap();
}
urlencoded is a part of Iron's core bundle.
HashMaps that maps String representations
of keys onto a Vec of String values.Vec to ensure that no information is lost if a key appears multiple times.
The query string a=b&a=c will result in a mapping from a to [b, c].application/x-www-form-urlencoded).If you're using Cargo to manage dependencies, just add urlencoded to Cargo.toml:
[dependencies.urlencoded]
version = "*"
Otherwise, cargo build, and the rlib will be in your target directory.
Along with the online documentation,
you can build a local copy with cargo doc.
One of us (@reem, @zzmp,
@theptrk, @mcreinhard)
is usually on #iron on the mozilla irc. Come say hi and ask any questions you might have.
We are also usually on #rust and #rust-webdev.