diff options
author | Jonathan de Jong <jonathan@automatia.nl> | 2022-02-13 12:07:00 +0100 |
---|---|---|
committer | Jonathan de Jong <jonathan@automatia.nl> | 2022-02-13 12:07:00 +0100 |
commit | b8d92d3cec4905265c1ef6aa9b03f1433e7d5637 (patch) | |
tree | 770af8bc88b2cff1908d41a8458bc5f12151fd99 /src/main.rs | |
parent | 0c4b42ac13be8ddf6f76a3b96a4ac4caff43fc82 (diff) | |
download | conduit-b8d92d3cec4905265c1ef6aa9b03f1433e7d5637.zip |
take advantage of multiple paths
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 22ddf3e..828d7dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -387,13 +387,19 @@ macro_rules! impl_ruma_handler { E: IntoResponse, $( $ty: FromRequest<axum::body::Body> + Send + 'static, )* { - fn add_to_router(self, router: Router) -> Router { + fn add_to_router(self, mut router: Router) -> Router { let meta = Req::Incoming::METADATA; let method_filter = method_to_filter(meta.method); - router.route(meta.path, on(method_filter, |$( $ty: $ty, )* req| async move { - self($($ty,)* req).await.map(RumaResponse) - })) + for path in IntoIterator::into_iter([meta.unstable_path, meta.r0_path, meta.stable_path]).flatten() { + let this = self.clone(); + + router = router.route(path, on(method_filter, |$( $ty: $ty, )* req| async move { + this($($ty,)* req).await.map(RumaResponse) + })) + } + + router } } }; |