diff options
author | Teddy Wing | 2018-11-10 13:58:03 +0100 |
---|---|---|
committer | Teddy Wing | 2018-11-10 13:58:32 +0100 |
commit | d87ed40cd99f6c7dae019cc13b0a16db65d847e5 (patch) | |
tree | d43ba5ed3f299af14fcac1449f67c55f10d208c2 | |
parent | db2c7627cb758f659111cd03d5f9984adca0b433 (diff) | |
download | dome-key-web-d87ed40cd99f6c7dae019cc13b0a16db65d847e5.tar.bz2 |
Parse POST params to a `BTreeMap`
We want a dictionary to be able to remove the Paddle `p_signature` entry.
-rw-r--r-- | license-generator/Cargo.lock | 1 | ||||
-rw-r--r-- | license-generator/Cargo.toml | 1 | ||||
-rw-r--r-- | license-generator/src/lib.rs | 2 | ||||
-rw-r--r-- | license-generator/src/main.rs | 5 | ||||
-rw-r--r-- | license-generator/src/params.rs | 14 |
5 files changed, 23 insertions, 0 deletions
diff --git a/license-generator/Cargo.lock b/license-generator/Cargo.lock index 09cad51..bf95a83 100644 --- a/license-generator/Cargo.lock +++ b/license-generator/Cargo.lock @@ -289,6 +289,7 @@ dependencies = [ "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/license-generator/Cargo.toml b/license-generator/Cargo.toml index 472f585..34a8c95 100644 --- a/license-generator/Cargo.toml +++ b/license-generator/Cargo.toml @@ -10,6 +10,7 @@ mysql = "14.1.1" rand = "0.5.5" sha1 = { version = "0.6.0", features = ["std"] } simplelog = "0.5.3" +url = "1.7.2" [workspace] members = [ diff --git a/license-generator/src/lib.rs b/license-generator/src/lib.rs index 8061142..64d96e9 100644 --- a/license-generator/src/lib.rs +++ b/license-generator/src/lib.rs @@ -4,8 +4,10 @@ extern crate log; extern crate mysql; extern crate rand; extern crate sha1; +extern crate url; pub mod database; pub mod errors; +pub mod params; pub mod purchaser; diff --git a/license-generator/src/main.rs b/license-generator/src/main.rs index d428af4..43a9d77 100644 --- a/license-generator/src/main.rs +++ b/license-generator/src/main.rs @@ -15,6 +15,7 @@ use simplelog::{Config, LevelFilter, WriteLogger}; use license_generator::database; use license_generator::errors::*; +use license_generator::params; use license_generator::purchaser::Purchaser; fn main() -> Result<()> { @@ -61,6 +62,10 @@ fn main() -> Result<()> { write!(&mut req.stdout(), "\n\nstdin: {}\n", stdin) .unwrap_or(()); + + let p = params::parse(&stdin); + write!(&mut req.stdout(), "\n{:?}\n", p) + .unwrap_or(()); }); Ok(()) diff --git a/license-generator/src/params.rs b/license-generator/src/params.rs new file mode 100644 index 0000000..80136c2 --- /dev/null +++ b/license-generator/src/params.rs @@ -0,0 +1,14 @@ +use std::collections::BTreeMap; + +use url::form_urlencoded; + +pub fn parse(params: &str) -> BTreeMap<String, String> { + let iter = form_urlencoded::parse(params.as_bytes()).into_owned(); + let mut dict = BTreeMap::new(); + + for (key, value) in iter { + dict.insert(key, value); + } + + dict +} |