aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/planets.rs
blob: e80e7fe4a37f5d99d7f327f53dbf487b9e41ce02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use axum::{response::IntoResponse, Json};

use tracing::{error, instrument};

use solarlib::star::Star;
use solarlib::planet::Planet;

use crate::errors::*;

pub async fn list() -> JsonResult<Json<Vec<Planet>>> {
    let con_url = std::env::var("QEMU_URL").unwrap_or("qemu:///system".to_string());
    let mut star = Star::new(con_url)?;
    
    let inhabitants = star.inhabitants()?;

    Ok(Json(inhabitants))
}