aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-12 04:57:09 +0100
committerTeddy Wing2018-11-12 04:57:09 +0100
commitc97f9f616b44c26eb12077aa85fb96831473c7ba (patch)
tree7eaa799d1bdf3b24404c74936d4963d2e1d08db2
parentebb5bda3c484f39f7e037954f47590ceba55137c (diff)
downloaddome-key-web-c97f9f616b44c26eb12077aa85fb96831473c7ba.tar.bz2
Add src/bin/license.rs
This binary will show a thank-you page to purchasers. I had also planned to make a third binary to send the license file as a Zip archive, but now I think I'm going to do that here too, working out the routing inside this program.
-rw-r--r--license-generator/src/bin/license.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/license-generator/src/bin/license.rs b/license-generator/src/bin/license.rs
new file mode 100644
index 0000000..81cd3f6
--- /dev/null
+++ b/license-generator/src/bin/license.rs
@@ -0,0 +1,61 @@
+///! FastCGI script that displays a thank-you page with a link to download a
+///! custom-generated license.
+
+extern crate fastcgi;
+
+#[macro_use]
+extern crate log;
+
+extern crate license_generator;
+
+use std::io::{Read, Write};
+
+use license_generator::errors::*;
+use license_generator::logger;
+
+fn main() -> Result<()> {
+ logger::init()?;
+
+ // let pool = match database::get_database_pool()
+ // .chain_err(|| "failed to create a database connection pool")
+ // {
+ // Ok(pool) => pool,
+ // Err(e) => {
+ // error!("{}", e);
+ // return Err(e);
+ // },
+ // };
+
+ fastcgi::run(move |mut req| {
+ let mut params = String::new();
+ match req.stdin().read_to_string(&mut params) {
+ Ok(_) => (),
+ Err(e) => error!("{}", e),
+ }
+
+ logger::log_request(&req, &params);
+
+ // method = req.param("REQUEST_METHOD")
+ // .unwrap_or("REQUEST_METHOD".into()),
+ // path = req.param("SCRIPT_NAME")
+ // .unwrap_or("SCRIPT_NAME".into()),
+ // query = req.param("QUERY_STRING")
+ // .unwrap_or("QUERY_STRING".into()),
+
+ if let Some(path) = req.param("REQUEST_URI") {
+ match path.as_ref() {
+ "/license" => {
+ // Get params name, email, secret
+ // Render thank-you page with link to download file
+ },
+ "/license/download" => {
+ // Send Zip file
+ // method POST
+ },
+ _ => (),
+ }
+ }
+ });
+
+ Ok(())
+}