use actix_web::{
HttpRequest, Responder, get,
web::{Data, Query},
};
use crate::AppState;
use super::super::catalog_responses::schema_overview_response;
use super::super::query_contracts::SchemaQuery;
use super::super::request_params::normalize_schema_query;
use super::super::schema_backend::require_schema_backend;
#[get("/schema")]
pub(in super::super) async fn schema_overview(
req: HttpRequest,
app_state: Data<AppState>,
query: Query<SchemaQuery>,
) -> impl Responder {
let schema_name: String = match normalize_schema_query(&query) {
Ok(value) => value,
Err(resp) => return resp,
};
let backend = match require_schema_backend(&req, app_state.get_ref()).await {
Ok(backend) => backend,
Err(resp) => return resp,
};
schema_overview_response(&backend, app_state.get_ref(), schema_name).await
}