diff options
-rw-r--r-- | Cargo.lock | 4 | ||||
-rw-r--r-- | src/handlers/planets.rs | 12 | ||||
-rw-r--r-- | src/main.rs | 3 |
3 files changed, 16 insertions, 3 deletions
@@ -862,8 +862,8 @@ dependencies = [ [[package]] name = "solarlib" -version = "1.4.0" -source = "git+https://git.carathe.dev/muirrum/solarlib?branch=master#137ec4c34aa962b11148cfad443a4c88035e3d87" +version = "1.4.1" +source = "git+https://git.carathe.dev/muirrum/solarlib?branch=master#f73eb90d830df1a0881447d918985e315aed6fb7" dependencies = [ "mac_address", "rand", diff --git a/src/handlers/planets.rs b/src/handlers/planets.rs index a57f605..ede7b2b 100644 --- a/src/handlers/planets.rs +++ b/src/handlers/planets.rs @@ -64,3 +64,15 @@ pub async fn pause(Path(uuid): Path<String>) -> NoneResult { Ok(()) } + +pub async fn reboot(Path(uuid): Path<String>) -> NoneResult { + let mut s = get_star()?; + + if let Ok(p) = s.find_planet(uuid) { + p.reboot()?; + } else { + return Err(ServiceError::NotFound); + } + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 28036d4..b962764 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ async fn main() { tracing_subscriber::registry() .with(tracing_subscriber::EnvFilter::new( std::env::var("RUST_LOG") - .unwrap_or_else(|_| "waifud=info,tower_http=debug".into()), + .unwrap_or_else(|_| "solard=info,tower_http=debug".into()), )) .with(tracing_subscriber::fmt::layer()) .init(); @@ -39,6 +39,7 @@ async fn main() { .route("/planets/:uuid/shutdown", post(handlers::planets::shutdown)) .route("/planets/:uuid/start", post(handlers::planets::start)) .route("/planets/:uuid/pause", post(handlers::planets::pause)) + .route("/planets/:uuid/reboot", post(handlers::planets::reboot)) .layer( ServiceBuilder::new() .layer(HandleErrorLayer::new(|error: BoxError| async move { if error.is::<tower::timeout::error::Elapsed>() { |