use pyo3::prelude::*; pub mod auth; pub mod background; pub mod buffer_test; mod dag; mod database; pub mod gil_pool; mod logging; #[cfg(feature = "mail")] mod mail; #[cfg(feature = "mail")] mod message_builder; mod multipart; mod native; #[cfg(feature = "redis-rate-limit")] mod rate_limit; mod request; pub mod scheduler; pub mod status; mod test_client; mod websocket; pub use auth::PyJwtAuth; pub use dag::{Dag, DagNode}; pub use database::{Database, DbParam, DbPool}; #[cfg(feature = "mail")] pub use mail::PyMailer; pub use multipart::UploadFile; pub use native::{validate_value, TokenStreamResponse, ValidatedStreamResponse}; #[cfg(feature = "redis-rate-limit")] pub use rate_limit::PyRateLimitResult; pub use request::{HTTPConnection, Headers, QueryParams, Request, RequestStream, State, URL}; pub use websocket::WebSocket; pub use websocket::WebSocketState; /// Start the server with hardcoded Rust routes only (no Python app). #[pyfunction] fn serve(addr: String) -> PyResult<()> { let addr: std::net::SocketAddr = addr .parse() .map_err(|e| pyo3::exceptions::PyValueError::new_err(format!("Invalid address: {}", e)))?; let rt = tokio::runtime::Runtime::new() .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("Runtime error: {}", e)))?; rt.block_on(async { let server = justapi_core::Server::new(addr); server .run() .await .map_err(|e| pyo3::exceptions::PyRuntimeError::new_err(format!("Server error: {}", e))) }) } #[pyfunction] fn _test_zero_copy(data: &[u8]) -> buffer_test::ZeroCopyBuffer { buffer_test::ZeroCopyBuffer::new(data.to_vec()) } #[pymodule] fn _justapi(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(serve, m)?)?; m.add_function(wrap_pyfunction!(validate_value, m)?)?; m.add_class::()?; auth::register(m)?; #[cfg(feature = "redis-rate-limit")] rate_limit::register(m)?; m.add_function(wrap_pyfunction!(_test_zero_copy, m)?)?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; #[cfg(feature = "mail")] m.add_class::()?; status::register(m)?; logging::register(m)?; Ok(()) }