aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-05-05 23:18:08 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-05-05 23:18:08 +0200
commit838dd2c1f903dd1d6da80983578a7da53139b4bb (patch)
tree5eaed65a168482bedf2d243f8caab6cc614b9c81
parentb7ecf8a824984ccfdff5af4e0e4193982ddc1a96 (diff)
add root switching endpoint
-rw-r--r--src/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 21730ab..382d1d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -123,6 +123,17 @@ async fn handle_update_root(data: web::Bytes) -> HttpResponse {
}
}
+async fn handle_switch() -> HttpResponse {
+ match switch_to_inactive_root() {
+ Ok(_) => HttpResponse::Ok()
+ .content_type(ContentType::plaintext())
+ .body("successfully switched to inactive root partition"),
+ Err(e) => HttpResponse::InternalServerError()
+ .content_type(ContentType::plaintext())
+ .body(format!("can't switch to inactive root partition: {}", e)),
+ }
+}
+
#[actix_web::main]
async fn main() -> io::Result<()> {
match start().await {
@@ -151,6 +162,7 @@ async fn start() -> Result<()> {
.service(web::resource("/update/boot").to(handle_update_boot))
.service(web::resource("/update/mbr").to(handle_update_mbr))
.service(web::resource("/update/root").to(handle_update_root))
+ .service(web::resource("/switch").to(handle_switch))
})
.bind_rustls("[::]:8443", config)?
.run()