From 51935aa8d927ee38b49687f0caa82dfbfbfdc9c5 Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Mon, 1 Jul 2019 11:57:55 +1000 Subject: [PATCH] Starting framework in place --- Cargo.toml | 8 ++++++++ src/main.rs | 31 +++++++++++++++++++++++++++++++ src/tests.rs | 15 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 src/tests.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..609dadf --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "desteg" +version = "0.1.0" +authors = ["pwarren"] +edition = "2018" + +[dependencies] +rocket="0.4.*" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4dd3a99 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,31 @@ +#![feature(proc_macro_hygiene, decl_macro)] + +#[macro_use] extern crate rocket; + +#[cfg(test)] mod tests; + +#[get("/")] +fn index() -> &'static str { + " + Usage + + POST / + + accepts image data in the body of the requests, returns the + image with more entropy added to the least significant bits of each + colour channel. + + EXMAPLE: curl --data-binary @file.jpg http://localhost:8000 +" +} + +fn rocket() -> rocket::Rocket { + let my_rocket = rocket::ignite().mount("/", routes![index]); + my_rocket +} + +fn main() { + rocket().launch(); +} + + diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 0000000..ef48625 --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,15 @@ +use super::rocket; +use rocket::local::Client; +use rocket::http::{Status, ContentType}; + +#[test] +fn check_index() { + let client = Client::new(rocket()).unwrap(); + + // Ensure the index returns what we expect. + let response = client.get("/").dispatch(); + assert_eq!(response.status(), Status::Ok); + assert_eq!(response.content_type(), Some(ContentType::Plain)); +} + +