rowt/src/rest/mod.rs

28 lines
644 B
Rust
Raw Normal View History

2023-03-26 14:40:56 +02:00
use rocket::{get, routes, Build, Rocket};
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
pub fn start() -> Rocket<Build> {
rocket::build().mount("/", routes![index])
}
#[cfg(test)]
mod test {
use super::start;
use rocket::http::Status;
use rocket::local::blocking::Client;
use rocket::uri;
#[test]
fn hello_world() {
let client = Client::tracked(start()).expect("valid rocket instance");
let response = client.get(uri!(super::index)).dispatch();
assert_eq!(response.status(), Status::Ok);
assert_eq!(response.into_string(), Some("Hello, world!".into()));
}
}