[closes #2] removed hello world endpoints

master
Jef Roosens 2021-04-05 09:59:40 +02:00
parent c0311132ec
commit 89bd29dc78
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
4 changed files with 0 additions and 47 deletions

View File

@ -1,21 +0,0 @@
#[cfg(test)]
mod tests;
pub fn routes() -> Vec<rocket::Route> {
routes![world, hello, name_age]
}
#[get("/world")]
fn world() -> &'static str {
"Hello, world!"
}
#[get("/<name>")]
fn hello(name: String) -> String {
format!("Hello, {}", name)
}
#[get("/world?<name>&<age>")]
fn name_age(name: String, age: u16) -> String {
format!("Hello, {} who is {} years old!", name, age)
}

View File

@ -1,24 +0,0 @@
use rocket::http::Status;
use rocket::local::Client;
fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", super::routes())
}
#[test]
fn test_world() {
let client = Client::new(rocket()).expect("valid rocket instance");
let mut response = client.get("/world").dispatch();
assert_eq!(response.status(), Status::Ok);
assert_eq!(response.body_string(), Some("Hello, world!".into()));
}
#[test]
fn test_hello() {
let client = Client::new(rocket()).expect("valid rocket instance");
let mut response = client.get("/thisisaname").dispatch();
assert_eq!(response.status(), Status::Ok);
assert_eq!(response.body_string(), Some("Hello, thisisaname".into()));
}

View File

@ -6,12 +6,10 @@ extern crate rocket;
// Route modules
mod catchers;
mod errors;
mod hello;
mod ivago;
fn rocket() -> rocket::Rocket {
rocket::ignite()
.mount("/hello", hello::routes())
.mount("/ivago", ivago::routes())
.register(catchers![catchers::not_found])
}