stately_arrow/
api.rs

1//! HTTP API module for stately-arrow.
2//!
3//! This module provides the axum router and handlers for the Arrow query API.
4
5pub mod handlers;
6pub mod ipc;
7pub mod openapi;
8
9use axum::Router;
10use axum::routing::{get, post};
11
12use crate::QuerySession;
13use crate::state::QueryState;
14
15/// Create the stately-arrow API router.
16///
17/// Mount this router at any path (e.g., `/api/v1/arrow` or `/arrow`).
18///
19/// # Example
20///
21/// ```rust,ignore
22/// use axum::Router;
23/// use stately_arrow::{api, QueryContext, QueryState};
24///
25/// let query_context = QueryContext::new(registry);
26/// let arrow_router = api::router(QueryState::new(query_context));
27///
28/// let app = Router::new().nest("/arrow", arrow_router);
29/// ```
30pub fn router<S, Session>(state: S) -> Router<S>
31where
32    S: Send + Sync + Clone + 'static,
33    QueryState<Session>: axum::extract::FromRef<S>,
34    Session: QuerySession + 'static,
35{
36    Router::new()
37        .route(
38            "/connectors",
39            get(handlers::list_connectors::<Session>)
40                .post(handlers::connector_list_many::<Session>),
41        )
42        .route("/connectors/{connector_id}", get(handlers::connector_list::<Session>))
43        .route("/register", get(handlers::list_registered::<Session>))
44        .route("/register/{connector_id}", get(handlers::register::<Session>))
45        .route("/catalogs", get(handlers::list_catalogs::<Session>))
46        .route("/query", post(handlers::execute_query::<Session>))
47        .with_state(state)
48}