diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers/planets.rs | 24 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/handlers/planets.rs b/src/handlers/planets.rs index ede7b2b..06773bc 100644 --- a/src/handlers/planets.rs +++ b/src/handlers/planets.rs @@ -76,3 +76,27 @@ pub async fn reboot(Path(uuid): Path<String>) -> NoneResult { Ok(()) } + +pub async fn force_reboot(Path(uuid): Path<String>) -> NoneResult { + let mut s = get_star()?; + + if let Ok(p) = s.find_planet(uuid) { + p.hard_reboot()?; + } else { + return Err(ServiceError::NotFound); + } + + Ok(()) +} + +pub async fn force_shutdown(Path(uuid): Path<String>) -> NoneResult { + let mut s = get_star()?; + + if let Ok(p) = s.find_planet(uuid) { + p.hard_shutdown()?; + } else { + return Err(ServiceError::NotFound); + } + + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index b962764..c235d41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,9 +37,11 @@ async fn main() { .route("/planets/list", get(handlers::planets::list)) .route("/planets/:uuid", get(handlers::planets::get)) .route("/planets/:uuid/shutdown", post(handlers::planets::shutdown)) + .route("/planets/:uuid/shutdown/hard", post(handlers::planets::force_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)) + .route("/planets/:uuid/reboot/hard", post(handlers::planets::force_reboot)) .layer( ServiceBuilder::new() .layer(HandleErrorLayer::new(|error: BoxError| async move { if error.is::<tower::timeout::error::Elapsed>() { |