diff --git a/examples/rocket_example/api/Rocket.toml b/examples/rocket_example/Rocket.toml similarity index 91% rename from examples/rocket_example/api/Rocket.toml rename to examples/rocket_example/Rocket.toml index fc294bd2f..41e0183c9 100644 --- a/examples/rocket_example/api/Rocket.toml +++ b/examples/rocket_example/Rocket.toml @@ -1,5 +1,5 @@ [default] -template_dir = "templates/" +template_dir = "api/templates/" [default.databases.sea_orm] # Mysql diff --git a/examples/rocket_example/api/Cargo.toml b/examples/rocket_example/api/Cargo.toml index e0d718d8e..1a88308fc 100644 --- a/examples/rocket_example/api/Cargo.toml +++ b/examples/rocket_example/api/Cargo.toml @@ -20,6 +20,7 @@ rocket_dyn_templates = { version = "0.1.0-rc.1", features = [ serde_json = { version = "^1" } entity = { path = "../entity" } migration = { path = "../migration" } +tokio = "1.20.0" [dependencies.sea-orm-rocket] path = "../../../sea-orm-rocket/lib" # remove this line in your own project and use the git line diff --git a/examples/rocket_example/api/src/lib.rs b/examples/rocket_example/api/src/lib.rs index f283b1015..51918c7a3 100644 --- a/examples/rocket_example/api/src/lib.rs +++ b/examples/rocket_example/api/src/lib.rs @@ -1,7 +1,6 @@ #[macro_use] extern crate rocket; -use futures::executor::block_on; use rocket::fairing::{self, AdHoc}; use rocket::form::{Context, Form}; use rocket::fs::{relative, FileServer}; @@ -144,7 +143,8 @@ async fn run_migrations(rocket: Rocket) -> fairing::Result { Ok(rocket) } -fn rocket() -> Rocket { +#[tokio::main] +async fn start() -> Result<(), rocket::Error> { rocket::build() .attach(Db::init()) .attach(AdHoc::try_on_ignite("Migrations", run_migrations)) @@ -155,10 +155,13 @@ fn rocket() -> Rocket { ) .register("/", catchers![not_found]) .attach(Template::fairing()) + .launch() + .await + .map(|_| ()) } pub fn main() { - let result = block_on(rocket().launch()); + let result = start(); println!("Rocket: deorbit.");