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 {
login: identity.user,
snapshot,
})
}
#[derive(serde::Serialize)]
pub struct Response {
pub login: User,
#[serde(flatten)]
pub snapshot: Snapshot,
}
impl IntoResponse for Response {
fn into_response(self) -> response::Response {
Json(self).into_response()
}
}
|