aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--license-generator/Cargo.lock1
-rw-r--r--license-generator/Cargo.toml1
-rw-r--r--license-generator/src/lib.rs2
-rw-r--r--license-generator/src/main.rs5
-rw-r--r--license-generator/src/params.rs14
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
+}