Skip to content

Commit

Permalink
Fix Rocket examples
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Sep 21, 2022
1 parent ac78c71 commit 32169c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[default]
template_dir = "templates/"
template_dir = "api/templates/"

[default.databases.sea_orm]
# Mysql
Expand Down
1 change: 1 addition & 0 deletions examples/rocket_example/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions examples/rocket_example/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -144,7 +143,8 @@ async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
Ok(rocket)
}

fn rocket() -> Rocket<Build> {
#[tokio::main]
async fn start() -> Result<(), rocket::Error> {
rocket::build()
.attach(Db::init())
.attach(AdHoc::try_on_ignite("Migrations", run_migrations))
Expand All @@ -155,10 +155,13 @@ fn rocket() -> Rocket<Build> {
)
.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.");

Expand Down

0 comments on commit 32169c0

Please sign in to comment.