@@ -322,7 +322,8 @@ derive_utoipa!(Icon as IconSchema);
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
paths(
|
||||
super::routes::health::status,
|
||||
super::routes::status::status,
|
||||
super::routes::status::diagnostics,
|
||||
super::routes::config_management::backup_config,
|
||||
super::routes::config_management::recover_config,
|
||||
super::routes::config_management::validate_config,
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
use axum::{routing::get, Router};
|
||||
|
||||
#[utoipa::path(get, path = "/status",
|
||||
responses(
|
||||
(status = 200, description = "ok", body = String),
|
||||
)
|
||||
)]
|
||||
async fn status() -> String {
|
||||
"ok".to_string()
|
||||
}
|
||||
|
||||
pub fn routes() -> Router {
|
||||
Router::new().route("/status", get(status))
|
||||
}
|
||||
@@ -4,13 +4,13 @@ pub mod config_management;
|
||||
pub mod context;
|
||||
pub mod errors;
|
||||
pub mod extension;
|
||||
pub mod health;
|
||||
pub mod recipe;
|
||||
pub mod recipe_utils;
|
||||
pub mod reply;
|
||||
pub mod schedule;
|
||||
pub mod session;
|
||||
pub mod setup;
|
||||
pub mod status;
|
||||
pub mod utils;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -19,7 +19,7 @@ use axum::Router;
|
||||
// Function to configure all routes
|
||||
pub fn configure(state: Arc<crate::state::AppState>) -> Router {
|
||||
Router::new()
|
||||
.merge(health::routes())
|
||||
.merge(status::routes())
|
||||
.merge(reply::routes(state.clone()))
|
||||
.merge(agent::routes(state.clone()))
|
||||
.merge(audio::routes(state.clone()))
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
use axum::body::Body;
|
||||
use axum::http::HeaderValue;
|
||||
use axum::response::IntoResponse;
|
||||
use axum::{extract::Path, http::StatusCode, routing::get, Router};
|
||||
use goose::session::generate_diagnostics;
|
||||
|
||||
#[utoipa::path(get, path = "/status",
|
||||
responses(
|
||||
(status = 200, description = "ok", body = String),
|
||||
)
|
||||
)]
|
||||
async fn status() -> String {
|
||||
"ok".to_string()
|
||||
}
|
||||
|
||||
#[utoipa::path(get, path = "/diagnostics/{session_id}",
|
||||
responses(
|
||||
(status = 200, description = "Diagnostics zip file", content_type = "application/zip", body = Vec<u8>),
|
||||
(status = 500, description = "Failed to generate diagnostics"),
|
||||
)
|
||||
)]
|
||||
async fn diagnostics(Path(session_id): Path<String>) -> impl IntoResponse {
|
||||
match generate_diagnostics(&session_id).await {
|
||||
Ok(zip_data) => {
|
||||
let filename = format!("attachment; filename=\"diagnostics_{}.zip\"", session_id);
|
||||
let headers = [
|
||||
(
|
||||
http::header::CONTENT_TYPE,
|
||||
HeaderValue::from_static("application/zip"),
|
||||
),
|
||||
(
|
||||
http::header::CONTENT_DISPOSITION,
|
||||
HeaderValue::from_str(&filename).map_err(|_e| StatusCode::BAD_REQUEST)?,
|
||||
),
|
||||
];
|
||||
|
||||
Ok((headers, Body::from(zip_data)))
|
||||
}
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
pub fn routes() -> Router {
|
||||
Router::new()
|
||||
.route("/status", get(status))
|
||||
.route("/diagnostics/{session_id}", get(diagnostics))
|
||||
}
|
||||
Reference in New Issue
Block a user