aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-06-09 10:28:42 -0400
committerCara Salter <cara@devcara.com>2022-06-09 10:28:42 -0400
commit276255f5a20fa05a005e765287239ca5ffe439e4 (patch)
tree67e325727fe49004d54deee702fb556a7d5ce1f1 /src/main.rs
parentbb545403fed8af5b746778c3336a4f3a371148d6 (diff)
downloadsolard-276255f5a20fa05a005e765287239ca5ffe439e4.tar.gz
solard-276255f5a20fa05a005e765287239ca5ffe439e4.zip
planets: State manipulation
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 8fbd0ff..742113e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,11 +2,12 @@ use axum::{
error_handling::HandleErrorLayer,
http::StatusCode,
response::IntoResponse,
- routing::get,
+ routing::{get, post},
Json, Router
};
use serde::{Deserialize, Serialize};
+use solarlib::star::Star;
use std::{net::SocketAddr, time::Duration, str::FromStr};
use tower::{BoxError, ServiceBuilder};
@@ -33,6 +34,10 @@ async fn main() {
let app = Router::new()
.route("/health", get(health_check))
.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/start", post(handlers::planets::start))
+ .route("/planets/:uuid/pause", post(handlers::planets::pause))
.layer( ServiceBuilder::new()
.layer(HandleErrorLayer::new(|error: BoxError| async move {
if error.is::<tower::timeout::error::Elapsed>() {
@@ -61,3 +66,9 @@ async fn main() {
async fn health_check() -> &'static str {
"OK"
}
+
+fn get_star() -> Result<Star, errors::ServiceError> {
+ let con_url = std::env::var("QEMU_URL").unwrap_or("qemu:///system".to_string());
+
+ Ok(Star::new(con_url)?)
+}