pub mod coercion;
pub mod headers;
pub mod mutation;
pub mod prefer;
pub mod query;
pub mod response;
pub mod routing;
pub mod search;
#[cfg(test)]
mod tests;
use std::sync::Arc;
use fraiseql_core::{
db::traits::DatabaseAdapter,
runtime::Executor,
schema::{CompiledSchema, RestConfig},
};
pub(crate) use headers::{set_preference_applied, set_request_id};
pub use prefer::{CountPreference, HandlingPreference, PreferHeader};
pub use response::{RestError, RestResponse};
pub use routing::{ResolvedGetQuery, ResolvedRoute};
use super::{idempotency::IdempotencyStore, resource::RestRouteTable};
pub struct RestHandler<'a, A: DatabaseAdapter> {
pub(super) executor: &'a Arc<Executor<A>>,
pub(super) schema: &'a CompiledSchema,
pub(super) config: &'a RestConfig,
pub(super) route_table: &'a RestRouteTable,
pub(super) idempotency_store: Option<&'a Arc<dyn IdempotencyStore>>,
}
impl<'a, A: DatabaseAdapter> RestHandler<'a, A> {
#[must_use]
pub const fn new(
executor: &'a Arc<Executor<A>>,
schema: &'a CompiledSchema,
config: &'a RestConfig,
route_table: &'a RestRouteTable,
) -> Self {
Self {
executor,
schema,
config,
route_table,
idempotency_store: None,
}
}
#[must_use]
pub const fn executor(&self) -> &Arc<Executor<A>> {
self.executor
}
#[must_use]
pub const fn config(&self) -> &RestConfig {
self.config
}
}