athena_rs 3.22.1

Hyper performant polyglot Database driver
Documentation
//! `/schema` catalog HTTP handler.
//!
//! This module owns request normalization, pool resolution, and response
//! orchestration for the schema overview endpoint.

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;

/// Returns full table/column structure for one schema.
///
/// Requires `X-Athena-Client`. Query parameter `schema_name` defaults to `public`.
#[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
}