1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//! # Reinhardt Routers
//!
//! URL routing for Reinhardt framework with advanced features:
//!
//! - **Namespace-based URL reversal**: Hierarchical route naming (`"api:v1:users:detail"`)
//! - **Nested namespace resolution**: Parent-child namespace relationships
//! - **Route introspection**: Runtime route analysis and debugging
//! - **OpenAPI integration**: Automatic OpenAPI schema generation from routes
//! - **Route visualization**: Generate route maps for documentation (ASCII, DOT, Markdown)
//! - **Per-route middleware**: Apply middleware to specific routes
//! - **Route group middleware**: Apply middleware to groups of routes
//!
//! # Examples
//!
//! ## Basic Routing
//!
//! ```
//! use reinhardt_urls::routers::{UnifiedRouter, Route};
//! use hyper::Method;
//!
//! let router = UnifiedRouter::new()
//! .with_prefix("/api/v1")
//! .with_namespace("v1");
//! ```
//!
//! ## Namespace-based URL Reversal
//!
//! ```
//! use reinhardt_urls::routers::namespace::{NamespaceResolver, Namespace};
//!
//! let mut resolver = NamespaceResolver::new();
//! resolver.register("api:v1:users:detail", "/api/v1/users/{id}/");
//!
//! let url = resolver.resolve("api:v1:users:detail", &[("id", "123")]).unwrap();
//! assert_eq!(url, "/api/v1/users/123/");
//! ```
//!
//! ## Route Introspection
//!
//! ```
//! use reinhardt_urls::routers::introspection::RouteInspector;
//! use hyper::Method;
//!
//! let mut inspector = RouteInspector::new();
//! inspector.add_route("/api/users/", vec![Method::GET], Some("api:users:list"), None);
//!
//! let routes = inspector.find_by_namespace("api");
//! assert_eq!(routes.len(), 1);
//! ```
//!
//! ## Route Visualization
//!
//! ```
//! use reinhardt_urls::routers::visualization::{RouteVisualizer, VisualizationFormat};
//! use reinhardt_urls::routers::introspection::RouteInspector;
//! use hyper::Method;
//!
//! let mut inspector = RouteInspector::new();
//! inspector.add_route("/users/", vec![Method::GET], Some("users:list"), None);
//!
//! let visualizer = RouteVisualizer::from_inspector(&inspector);
//! let tree = visualizer.render(VisualizationFormat::Tree);
//! println!("{}", tree);
//! ```
//!
//! ## Per-Route Middleware
//!
//! ```rust,no_run
//! use reinhardt_urls::routers::UnifiedRouter;
//! use reinhardt_middleware::LoggingMiddleware;
//! use hyper::Method;
//! # use reinhardt_http::{Request, Response, Result};
//!
//! # async fn handler(_req: Request) -> Result<Response> {
//! # Ok(Response::ok())
//! # }
//! let router = UnifiedRouter::new()
//! .function("/api/users", Method::GET, handler)
//! .with_middleware(LoggingMiddleware::new());
//! ```
//!
//! ## Route Group Middleware
//!
//! ```rust,no_run
//! use reinhardt_urls::routers::RouteGroup;
//! use reinhardt_middleware::LoggingMiddleware;
//! use hyper::Method;
//! # use reinhardt_http::{Request, Response, Result};
//!
//! # async fn users_list(_req: Request) -> Result<Response> {
//! # Ok(Response::ok())
//! # }
//! # async fn users_detail(_req: Request) -> Result<Response> {
//! # Ok(Response::ok())
//! # }
//! // Create a group with middleware
//! let group = RouteGroup::new()
//! .with_prefix("/api/v1")
//! .with_middleware(LoggingMiddleware::new())
//! .function("/users", Method::GET, users_list)
//! .function("/users/{id}", Method::GET, users_detail);
//!
//! let router = group.build();
//! ```
// Client router (WASM-compatible)
// Server-only modules (not available on WASM)
/// Route matching result cache for repeated lookups.
/// Path parameter type converters (integer, UUID, slug, date, etc.).
/// Helper functions for building routes (similar to Django's `path()` and `re_path()`).
/// Route introspection and analysis utilities.
/// Hierarchical namespace management for URL resolution.
/// OpenAPI specification generation from registered routes.
/// URL path joining and normalization utilities.
pub
/// Path pattern matching and radix tree routing.
/// Compile-time URL pattern registration via `inventory`.
///
/// On native targets exposes `UrlPatternsRegistration`; on
/// `wasm32-unknown-unknown` exposes `ClientRouterRegistration` and
/// `collect_client_router_from_inventory` (refs #4453).
/// URL resolver trait for type-safe URL generation.
/// URL reverse resolution (name-to-URL mapping).
/// Route definition combining path patterns with handlers.
/// Route grouping with shared prefix and middleware.
/// Router trait and default implementation.
/// SCRIPT_NAME prefix management for reverse proxy deployments.
/// Full HTTP routing implementation with global router management.
/// Minimal router for simple routing use cases.
/// Unified router combining server and client routing.
/// `VersionedRouter` trait impls bridging concrete routers to the
/// `reinhardt-router` crate (issue #4321).
/// Route map visualization in multiple formats (tree, DOT, Markdown).
// Re-export the path! macro for compile-time path validation.
pub use path;
pub use RouteCache;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Route;
pub use ;
pub use ;
pub use ;
pub use SimpleRouter;
// Server router (full HTTP routing implementation)
pub use ;
// On WASM with `client-router`, `ServerRouter` is the no-op builder defined in
// `unified_router`. Re-exported here so `reinhardt_urls::routers::ServerRouter`
// resolves uniformly on both targets (issue #4569). The native re-export above
// and this one are gated on mutually exclusive cfgs, so exactly one is active.
pub use ServerRouter;
// Unified router (closure-based API combining server and client routers)
pub use UnifiedRouter;
// Client router re-exports
pub use ;
pub use ;
// Re-export the canonical `StreamingTopicResolver` trait from
// `reinhardt-streaming` so downstream users can keep importing it from
// `reinhardt_urls::routers`.
pub use StreamingTopicResolver;