add user table
This commit is contained in:
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod rest;
|
@ -1,7 +1,11 @@
|
||||
use rot::rest;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
#[launch]
|
||||
async fn rocket() -> _ {
|
||||
env_logger::init();
|
||||
|
||||
rest::start()
|
||||
}
|
||||
|
27
src/rest/mod.rs
Normal file
27
src/rest/mod.rs
Normal file
@ -0,0 +1,27 @@
|
||||
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()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user