From c97f9f616b44c26eb12077aa85fb96831473c7ba Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 12 Nov 2018 04:57:09 +0100 Subject: 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. --- license-generator/src/bin/license.rs | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 license-generator/src/bin/license.rs (limited to 'license-generator/src') 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, ¶ms); + + // 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(()) +} -- cgit v1.2.3