From: Ian Jackson Date: Sat, 11 Jul 2020 22:36:53 +0000 (+0100) Subject: mount things again X-Git-Tag: otter-0.2.0~1384 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=adabdca8ea3320fe044732862cdecaad823926f0;p=otter.git mount things again --- diff --git a/src/api.rs b/src/api.rs index 530ee58f..17a80db0 100644 --- a/src/api.rs +++ b/src/api.rs @@ -238,10 +238,11 @@ impl ApiPieceOp for ApiPieceMove { } } -/* - api_grab, - api_ungrab, - api_raise, - api_move, -xxx -*/ +pub fn mount(rocket_instance: Rocket) -> Rocket { + return rocket_instance.mount("/", routes![ + api_grab, + api_ungrab, + api_raise, + api_move, + ]); +} diff --git a/src/bin/server.rs b/src/bin/server.rs index e0fb2967..0c9609f5 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -76,7 +76,7 @@ fn main() { .enable(Frame::Deny) .enable(Referrer::NoReferrer); - let mut r = rocket::ignite() + let r = rocket::ignite() .attach(helmet) .attach(Template::fairing()) .mount("/", routes![ @@ -85,6 +85,7 @@ fn main() { resource, updates, ]); - game::session::mount(&mut r); + let r = game::session::mount(r); + let r = game::api::mount(r); r.launch(); } diff --git a/src/http.rs b/src/http.rs index ec31f2a2..9751e372 100644 --- a/src/http.rs +++ b/src/http.rs @@ -1,7 +1,7 @@ pub use rocket::request::Request; pub use rocket::response::{Response,Responder}; -pub use rocket::post; +pub use rocket::{post,get,routes}; pub use rocket_contrib::json::Json; pub use rocket::http::Status; diff --git a/src/session.rs b/src/session.rs index 7b37d38a..0f87175d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -91,6 +91,8 @@ fn session(form : Json) -> Result { Ok(Template::render("session",&c)) } -pub fn mount(_rocket_instance: &mut Rocket) { - //rocket_instance.mount(&session); xxx +pub fn mount(rocket_instance: Rocket) -> Rocket { + return rocket_instance.mount("/", routes![ + session, + ]); }