Skip to main content

reinhardt_urls/
lib.rs

1//! URL routing and proxy utilities for Reinhardt framework.
2//!
3//! This crate provides URL routing, pattern matching, and proxy functionality
4//! for the Reinhardt web framework. It is a unified interface over the following
5//! internal crates:
6//!
7//! - `reinhardt-routers`: URL routing and pattern matching with middleware support
8//! - `reinhardt-routers-macros`: Compile-time URL validation macros
9//! - `reinhardt-proxy`: Lazy relationship loading for ORM
10//!
11//! ## Features
12//!
13//! ### Route Middleware Support
14//!
15//! Per-route middleware configuration is now available. You can attach middleware
16//! to specific routes or route groups:
17//!
18//! ```rust,ignore
19//! # use reinhardt_urls::routers::UnifiedRouter;
20//! # use hyper::Method;
21//! # use reinhardt_http::{Request, Response};
22//! # use reinhardt_core::exception::Result;
23//!
24//! # async fn handler(_req: Request) -> Result<Response> { Ok(Response::ok()) }
25//! # async fn users_handler(_req: Request) -> Result<Response> { Ok(Response::ok()) }
26//! # async fn settings_handler(_req: Request) -> Result<Response> { Ok(Response::ok()) }
27//! let router = UnifiedRouter::new()
28//!     .function("/public", Method::GET, handler)
29//!     .function("/protected", Method::GET, handler);
30//!     // .with_route_middleware(...) // Route-specific middleware
31//! ```
32//!
33//! **Features**:
34//! - Per-route middleware configuration
35//! - Route group middleware with inheritance
36//! - Middleware composition and chaining
37//! - Proper execution order: global → group → route → handler
38//!
39//! See `reinhardt-routers` crate documentation for detailed usage and examples.
40
41#![cfg_attr(docsrs, feature(doc_cfg))]
42
43pub mod proxy;
44pub mod routers;
45
46#[cfg(feature = "routers-macros")]
47#[cfg_attr(docsrs, doc(cfg(feature = "routers-macros")))]
48pub use reinhardt_routers_macros as routers_macros;
49
50// Re-export commonly used types from routers
51#[cfg(feature = "routers")]
52#[cfg_attr(docsrs, doc(cfg(feature = "routers")))]
53pub mod prelude {
54	pub use crate::routers::{
55		PathPattern, Route, RouteGroup, Router, ServerRouter, UnifiedRouter, clear_script_prefix,
56		get_script_prefix, set_script_prefix,
57	};
58}