Starting framework in place
This commit is contained in:
parent
144125e61e
commit
51935aa8d9
3 changed files with 54 additions and 0 deletions
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "desteg"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["pwarren"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rocket="0.4.*"
|
31
src/main.rs
Normal file
31
src/main.rs
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
15
src/tests.rs
Normal file
15
src/tests.rs
Normal file
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue