From 82cd5b8290d70c2a4fdb1e953fea8a13555fdde7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 20 Jul 2021 07:43:50 +0100 Subject: [PATCH] prepare router release 0.5.0-beta.1 --- actix-router/CHANGES.md | 3 +++ actix-router/Cargo.toml | 4 ++-- actix-router/src/lib.rs | 2 +- actix-router/src/router.rs | 18 ++++++++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 8ce805bf..49248d05 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx + + +## 0.5.0-beta.1 - 2021-07-20 * Fix a bug in multi-patterns where static patterns are interpreted as regex. [#366] * Introduce `ResourceDef::pattern_iter` to get an iterator over all patterns in a multi-pattern resource. [#373] * Fix segment interpolation leaving `Path` in unintended state after matching. [#368] diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index b0bcd9da..2a2ce1cc 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "actix-router" -version = "0.4.0" +version = "0.5.0-beta.1" authors = [ "Nikolay Kim ", "Ali MJ Al-Nasrawy ", "Rob Ede ", ] -description = "Resource path matching library" +description = "Resource path matching and router" keywords = ["actix", "router", "routing"] repository = "https://github.com/actix/actix-net.git" license = "MIT OR Apache-2.0" diff --git a/actix-router/src/lib.rs b/actix-router/src/lib.rs index 6082c1a3..f08b25a8 100644 --- a/actix-router/src/lib.rs +++ b/actix-router/src/lib.rs @@ -1,4 +1,4 @@ -//! Resource path matching library. +//! Resource path matching and router. #![deny(rust_2018_idioms, nonstandard_style)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] diff --git a/actix-router/src/router.rs b/actix-router/src/router.rs index 057f7e17..f5deb858 100644 --- a/actix-router/src/router.rs +++ b/actix-router/src/router.rs @@ -12,7 +12,11 @@ pub struct ResourceInfo { } /// Resource router. -pub struct Router(Vec<(ResourceDef, T, Option)>); +// T is the resource itself +// U is any other data needed for routing like method guards +pub struct Router { + routes: Vec<(ResourceDef, T, Option)>, +} impl Router { pub fn build() -> RouterBuilder { @@ -28,7 +32,7 @@ impl Router { { profile_method!(recognize); - for item in self.0.iter() { + for item in self.routes.iter() { if item.0.capture_match_info(resource.resource_path()) { return Some((&item.1, ResourceId(item.0.id()))); } @@ -44,7 +48,7 @@ impl Router { { profile_method!(recognize_mut); - for item in self.0.iter_mut() { + for item in self.routes.iter_mut() { if item.0.capture_match_info(resource.resource_path()) { return Some((&mut item.1, ResourceId(item.0.id()))); } @@ -61,7 +65,7 @@ impl Router { { profile_method!(recognize_checked); - for item in self.0.iter() { + for item in self.routes.iter() { if item.0.capture_match_info_fn(resource, &check, &item.2) { return Some((&item.1, ResourceId(item.0.id()))); } @@ -82,7 +86,7 @@ impl Router { { profile_method!(recognize_mut_checked); - for item in self.0.iter_mut() { + for item in self.routes.iter_mut() { if item.0.capture_match_info_fn(resource, &check, &item.2) { return Some((&mut item.1, ResourceId(item.0.id()))); } @@ -129,7 +133,9 @@ impl RouterBuilder { /// Finish configuration and create router instance. pub fn finish(self) -> Router { - Router(self.resources) + Router { + routes: self.resources, + } } }