summaryrefslogtreecommitdiff
path: root/src/boot/routes/get.rs
blob: 4873b7a6e8e19a0812133dfd4c806c081adeba1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use axum::{
    extract::{Json, State},
    response::{self, IntoResponse},
};

use crate::{app::App, boot::Snapshot, error::Internal, token::extract::Identity, user::User};

pub async fn handler(State(app): State<App>, identity: Identity) -> Result<Response, Internal> {
    let snapshot = app.boot().snapshot().await?;
    Ok(Response {
        user: identity.user,
        snapshot,
    })
}

#[derive(serde::Serialize)]
pub struct Response {
    pub user: User,
    #[serde(flatten)]
    pub snapshot: Snapshot,
}

impl IntoResponse for Response {
    fn into_response(self) -> response::Response {
        Json(self).into_response()
    }
}