diff --git a/crates/core/src/routing/router.rs b/crates/core/src/routing/router.rs index d1e4531bc..23b1e27fc 100644 --- a/crates/core/src/routing/router.rs +++ b/crates/core/src/routing/router.rs @@ -264,7 +264,7 @@ impl Router { /// /// [`HostFilter`]: super::filters::HostFilter #[inline] - pub fn with_host(self, host: impl Into) -> Self { + pub fn with_host(host: impl Into) -> Self { Router::with_filter(filters::host(host)) } @@ -276,6 +276,14 @@ impl Router { self.filter(filters::port(port)) } + /// Create a new [`PortFilter`] and set port filter. + /// + /// [`PortFilter`]: super::filters::PortFilter + #[inline] + pub fn with_port(port: u16) -> Self { + Router::with_filter(filters::port(port)) + } + /// Create a new child router with [`MethodFilter`] to filter get method and set this child router's handler. /// /// [`MethodFilter`]: super::filters::MethodFilter