reifydb_sub_server_http/
lib.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later
3
4//! HTTP server subsystem for ReifyDB.
5//!
6//! This crate provides an Axum-based HTTP server for handling query and command
7//! requests. It integrates with the shared tokio runtime and implements the
8//! standard ReifyDB `Subsystem` trait for lifecycle management.
9//!
10//! # Features
11//!
12//! - REST API for query and command execution
13//! - Bearer token and API key authentication
14//! - Request timeouts and connection limits
15//! - Graceful shutdown support
16//! - Health check endpoint
17//!
18//! # Endpoints
19//!
20//! - `GET /health` - Health check (no authentication required)
21//! - `POST /v1/query` - Execute read-only queries
22//! - `POST /v1/command` - Execute write commands
23//!
24//! # Example
25//!
26//! ```ignore
27//! use reifydb_sub_server::{AppState, QueryConfig, SharedRuntime};
28//! use reifydb_sub_server_http::HttpSubsystem;
29//!
30//! // Create shared runtime
31//! let runtime = SharedRuntime::new(4);
32//!
33//! // Create application state
34//! let state = AppState::new(engine, QueryConfig::default());
35//!
36//! // Create and start HTTP subsystem
37//! let mut http = HttpSubsystem::new(
38//!     "0.0.0.0:8090".to_string(),
39//!     state,
40//!     runtime.handle(),
41//! );
42//! http.start()?;
43//! ```
44
45#![cfg_attr(not(debug_assertions), deny(warnings))]
46
47pub mod error;
48pub mod factory;
49pub mod handlers;
50pub mod routes;
51pub mod subsystem;
52
53pub use error::{AppError, ErrorResponse};
54pub use factory::{HttpConfig, HttpSubsystemFactory};
55pub use handlers::{QueryResponse, StatementRequest};
56pub use routes::router;
57pub use subsystem::HttpSubsystem;