Adds utoipa-based OpenAPI 3.1 documentation: - OpenAPI module with API metadata, server info, and tags - Security scheme definitions (API key and JWT bearer) - ToSchema derives for response types - JSON specification generation endpoint
69 lines
4.3 KiB
Rust
69 lines
4.3 KiB
Rust
//! # Synor API Gateway
|
|
//!
|
|
//! Unified REST API gateway for all Synor blockchain services.
|
|
//!
|
|
//! ## Architecture
|
|
//!
|
|
//! ```text
|
|
//! ┌──────────────────────────────────────────────────────────────────┐
|
|
//! │ Synor API Gateway │
|
|
//! ├──────────────────────────────────────────────────────────────────┤
|
|
//! │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
//! │ │ REST API │ │ WebSocket │ │ Metrics │ │
|
|
//! │ │ /v1/* │ │ /ws │ │ /metrics │ │
|
|
//! │ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
//! │ │ │ │ │
|
|
//! │ ┌──────┴─────────────────┴─────────────────┴───────────────┐ │
|
|
//! │ │ Middleware Layer │ │
|
|
//! │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────────┐ │ │
|
|
//! │ │ │ Auth │ │ Rate │ │ CORS │ │ Request Tracing │ │ │
|
|
//! │ │ │ │ │ Limit │ │ │ │ │ │ │
|
|
//! │ │ └─────────┘ └─────────┘ └─────────┘ └─────────────────┘ │ │
|
|
//! │ └──────────────────────────────────────────────────────────┘ │
|
|
//! │ │ │ │ │
|
|
//! │ ┌──────┴─────────────────┴─────────────────┴───────────────┐ │
|
|
//! │ │ Service Routers │ │
|
|
//! │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
|
|
//! │ │ │ Wallet │ │ RPC │ │ Storage │ │ DEX │ ... │ │
|
|
//! │ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │
|
|
//! │ └──────────────────────────────────────────────────────────┘ │
|
|
//! └──────────────────────────────────────────────────────────────────┘
|
|
//! ```
|
|
//!
|
|
//! ## Features
|
|
//!
|
|
//! - **REST API**: RESTful endpoints for all services
|
|
//! - **OpenAPI**: Auto-generated OpenAPI 3.1 documentation
|
|
//! - **WebSocket**: Real-time event subscriptions
|
|
//! - **Authentication**: API key and JWT authentication
|
|
//! - **Rate Limiting**: Configurable per-endpoint rate limits
|
|
//! - **Metrics**: Prometheus-compatible metrics export
|
|
//!
|
|
//! ## Quick Start
|
|
//!
|
|
//! ```rust,no_run
|
|
//! use synor_gateway::{Gateway, GatewayConfig};
|
|
//!
|
|
//! #[tokio::main]
|
|
//! async fn main() -> anyhow::Result<()> {
|
|
//! let config = GatewayConfig::default();
|
|
//! let gateway = Gateway::new(config)?;
|
|
//! gateway.serve().await
|
|
//! }
|
|
//! ```
|
|
|
|
pub mod auth;
|
|
pub mod config;
|
|
pub mod error;
|
|
pub mod middleware;
|
|
#[cfg(feature = "openapi")]
|
|
pub mod openapi;
|
|
pub mod response;
|
|
pub mod routes;
|
|
pub mod server;
|
|
|
|
// Re-exports
|
|
pub use config::GatewayConfig;
|
|
pub use error::{ApiError, ApiResult};
|
|
pub use response::ApiResponse;
|
|
pub use server::Gateway;
|