blob: 5f9996bb51c288b0cf9926f789b4957f70cccadc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
use axum::{
extract::{Request, State},
http::StatusCode,
middleware::Next,
response::{IntoResponse, Response},
};
use crate::{app::App, error::Internal};
pub async fn setup_required(State(app): State<App>, request: Request, next: Next) -> Response {
match app.setup().completed().await {
Ok(true) => next.run(request).await,
Ok(false) => (
StatusCode::SERVICE_UNAVAILABLE,
"initial setup not completed",
)
.into_response(),
Err(error) => Internal::from(error).into_response(),
}
}
|