mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-22 23:35:07 +02:00
Compare commits
9 Commits
service-v0
...
connect-v0
Author | SHA1 | Date | |
---|---|---|---|
|
a4e0c71baa | ||
|
b9ea445e70 | ||
|
ba2901269d | ||
|
5cbc29306a | ||
|
810fa869ae | ||
|
33cd51aabf | ||
|
629ed05f82 | ||
|
5e8ae210f7 | ||
|
3add90628f |
@@ -1,5 +1,16 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.2] - 2019-04-04
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Log error if dns system config could not be loaded.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Rename connect Connector to TcpConnector #10
|
||||||
|
|
||||||
|
|
||||||
## [0.1.1] - 2019-03-15
|
## [0.1.1] - 2019-03-15
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-connect"
|
name = "actix-connect"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix Connector - tcp connector service"
|
description = "Actix Connector - tcp connector service"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
@@ -12,54 +12,54 @@ use super::error::ConnectError;
|
|||||||
|
|
||||||
/// Tcp connector service factory
|
/// Tcp connector service factory
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConnectorFactory<T>(PhantomData<T>);
|
pub struct TcpConnectorFactory<T>(PhantomData<T>);
|
||||||
|
|
||||||
impl<T> ConnectorFactory<T> {
|
impl<T> TcpConnectorFactory<T> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
ConnectorFactory(PhantomData)
|
TcpConnectorFactory(PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for ConnectorFactory<T> {
|
impl<T> Clone for TcpConnectorFactory<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
ConnectorFactory(PhantomData)
|
TcpConnectorFactory(PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Address> NewService for ConnectorFactory<T> {
|
impl<T: Address> NewService for TcpConnectorFactory<T> {
|
||||||
type Request = Connect<T>;
|
type Request = Connect<T>;
|
||||||
type Response = Connection<T, TcpStream>;
|
type Response = Connection<T, TcpStream>;
|
||||||
type Error = ConnectError;
|
type Error = ConnectError;
|
||||||
type Service = Connector<T>;
|
type Service = TcpConnector<T>;
|
||||||
type InitError = ();
|
type InitError = ();
|
||||||
type Future = FutureResult<Self::Service, Self::InitError>;
|
type Future = FutureResult<Self::Service, Self::InitError>;
|
||||||
|
|
||||||
fn new_service(&self, _: &()) -> Self::Future {
|
fn new_service(&self, _: &()) -> Self::Future {
|
||||||
ok(Connector(PhantomData))
|
ok(TcpConnector(PhantomData))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tcp connector service
|
/// Tcp connector service
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Connector<T>(PhantomData<T>);
|
pub struct TcpConnector<T>(PhantomData<T>);
|
||||||
|
|
||||||
impl<T> Connector<T> {
|
impl<T> TcpConnector<T> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Connector(PhantomData)
|
TcpConnector(PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for Connector<T> {
|
impl<T> Clone for TcpConnector<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Connector(PhantomData)
|
TcpConnector(PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Address> Service for Connector<T> {
|
impl<T: Address> Service for TcpConnector<T> {
|
||||||
type Request = Connect<T>;
|
type Request = Connect<T>;
|
||||||
type Response = Connection<T, TcpStream>;
|
type Response = Connection<T, TcpStream>;
|
||||||
type Error = ConnectError;
|
type Error = ConnectError;
|
||||||
type Future = Either<ConnectorResponse<T>, FutureResult<Self::Response, Self::Error>>;
|
type Future = Either<TcpConnectorResponse<T>, FutureResult<Self::Response, Self::Error>>;
|
||||||
|
|
||||||
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
||||||
Ok(Async::Ready(()))
|
Ok(Async::Ready(()))
|
||||||
@@ -70,7 +70,7 @@ impl<T: Address> Service for Connector<T> {
|
|||||||
let Connect { req, addr, .. } = req;
|
let Connect { req, addr, .. } = req;
|
||||||
|
|
||||||
if let Some(addr) = addr {
|
if let Some(addr) = addr {
|
||||||
Either::A(ConnectorResponse::new(req, port, addr))
|
Either::A(TcpConnectorResponse::new(req, port, addr))
|
||||||
} else {
|
} else {
|
||||||
error!("TCP connector: got unresolved address");
|
error!("TCP connector: got unresolved address");
|
||||||
Either::B(err(ConnectError::Unresolverd))
|
Either::B(err(ConnectError::Unresolverd))
|
||||||
@@ -80,19 +80,19 @@ impl<T: Address> Service for Connector<T> {
|
|||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// Tcp stream connector response future
|
/// Tcp stream connector response future
|
||||||
pub struct ConnectorResponse<T> {
|
pub struct TcpConnectorResponse<T> {
|
||||||
req: Option<T>,
|
req: Option<T>,
|
||||||
port: u16,
|
port: u16,
|
||||||
addrs: Option<VecDeque<SocketAddr>>,
|
addrs: Option<VecDeque<SocketAddr>>,
|
||||||
stream: Option<ConnectFuture>,
|
stream: Option<ConnectFuture>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Address> ConnectorResponse<T> {
|
impl<T: Address> TcpConnectorResponse<T> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
req: T,
|
req: T,
|
||||||
port: u16,
|
port: u16,
|
||||||
addr: either::Either<SocketAddr, VecDeque<SocketAddr>>,
|
addr: either::Either<SocketAddr, VecDeque<SocketAddr>>,
|
||||||
) -> ConnectorResponse<T> {
|
) -> TcpConnectorResponse<T> {
|
||||||
trace!(
|
trace!(
|
||||||
"TCP connector - connecting to {:?} port:{}",
|
"TCP connector - connecting to {:?} port:{}",
|
||||||
req.host(),
|
req.host(),
|
||||||
@@ -100,13 +100,13 @@ impl<T: Address> ConnectorResponse<T> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
match addr {
|
match addr {
|
||||||
either::Either::Left(addr) => ConnectorResponse {
|
either::Either::Left(addr) => TcpConnectorResponse {
|
||||||
req: Some(req),
|
req: Some(req),
|
||||||
port,
|
port,
|
||||||
addrs: None,
|
addrs: None,
|
||||||
stream: Some(TcpStream::connect(&addr)),
|
stream: Some(TcpStream::connect(&addr)),
|
||||||
},
|
},
|
||||||
either::Either::Right(addrs) => ConnectorResponse {
|
either::Either::Right(addrs) => TcpConnectorResponse {
|
||||||
req: Some(req),
|
req: Some(req),
|
||||||
port,
|
port,
|
||||||
addrs: Some(addrs),
|
addrs: Some(addrs),
|
||||||
@@ -116,7 +116,7 @@ impl<T: Address> ConnectorResponse<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Address> Future for ConnectorResponse<T> {
|
impl<T: Address> Future for TcpConnectorResponse<T> {
|
||||||
type Item = Connection<T, TcpStream>;
|
type Item = Connection<T, TcpStream>;
|
||||||
type Error = ConnectError;
|
type Error = ConnectError;
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ mod uri;
|
|||||||
pub use trust_dns_resolver::{error::ResolveError, AsyncResolver};
|
pub use trust_dns_resolver::{error::ResolveError, AsyncResolver};
|
||||||
|
|
||||||
pub use self::connect::{Address, Connect, Connection};
|
pub use self::connect::{Address, Connect, Connection};
|
||||||
pub use self::connector::{Connector, ConnectorFactory};
|
pub use self::connector::{TcpConnector, TcpConnectorFactory};
|
||||||
pub use self::error::ConnectError;
|
pub use self::error::ConnectError;
|
||||||
pub use self::resolver::{Resolver, ResolverFactory};
|
pub use self::resolver::{Resolver, ResolverFactory};
|
||||||
|
|
||||||
@@ -29,6 +29,17 @@ use tokio_tcp::TcpStream;
|
|||||||
use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
|
use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
|
||||||
use trust_dns_resolver::system_conf::read_system_conf;
|
use trust_dns_resolver::system_conf::read_system_conf;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[deprecated(since = "0.1.2", note = "please use `actix_connect::TcpConnector`")]
|
||||||
|
pub type Connector<T> = TcpConnector<T>;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.1.2",
|
||||||
|
note = "please use `actix_connect::TcpConnectorFactory`"
|
||||||
|
)]
|
||||||
|
pub type ConnectorFactory<T> = TcpConnectorFactory<T>;
|
||||||
|
|
||||||
pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver {
|
pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver {
|
||||||
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
||||||
tokio_current_thread::spawn(bg);
|
tokio_current_thread::spawn(bg);
|
||||||
@@ -36,10 +47,12 @@ pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_default_resolver() -> AsyncResolver {
|
pub fn start_default_resolver() -> AsyncResolver {
|
||||||
let (cfg, opts) = if let Ok((cfg, opts)) = read_system_conf() {
|
let (cfg, opts) = match read_system_conf() {
|
||||||
(cfg, opts)
|
Ok((cfg, opts)) => (cfg, opts),
|
||||||
} else {
|
Err(e) => {
|
||||||
(ResolverConfig::default(), ResolverOpts::default())
|
log::error!("TRust-DNS can not load system config: {}", e);
|
||||||
|
(ResolverConfig::default(), ResolverOpts::default())
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
||||||
@@ -52,7 +65,7 @@ pub fn new_connector<T: Address>(
|
|||||||
resolver: AsyncResolver,
|
resolver: AsyncResolver,
|
||||||
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
|
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
|
||||||
+ Clone {
|
+ Clone {
|
||||||
Resolver::new(resolver).and_then(Connector::new())
|
Resolver::new(resolver).and_then(TcpConnector::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create tcp connector service
|
/// Create tcp connector service
|
||||||
@@ -64,14 +77,14 @@ pub fn new_connector_factory<T: Address>(
|
|||||||
Error = ConnectError,
|
Error = ConnectError,
|
||||||
InitError = (),
|
InitError = (),
|
||||||
> + Clone {
|
> + Clone {
|
||||||
ResolverFactory::new(resolver).and_then(ConnectorFactory::new())
|
ResolverFactory::new(resolver).and_then(TcpConnectorFactory::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create connector service with default parameters
|
/// Create connector service with default parameters
|
||||||
pub fn default_connector<T: Address>(
|
pub fn default_connector<T: Address>(
|
||||||
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
|
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
|
||||||
+ Clone {
|
+ Clone {
|
||||||
Resolver::new(start_default_resolver()).and_then(Connector::new())
|
Resolver::new(start_default_resolver()).and_then(TcpConnector::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create connector service factory with default parameters
|
/// Create connector service factory with default parameters
|
||||||
@@ -81,5 +94,5 @@ pub fn default_connector_factory<T: Address>() -> impl NewService<
|
|||||||
Error = ConnectError,
|
Error = ConnectError,
|
||||||
InitError = (),
|
InitError = (),
|
||||||
> + Clone {
|
> + Clone {
|
||||||
ResolverFactory::new(start_default_resolver()).and_then(ConnectorFactory::new())
|
ResolverFactory::new(start_default_resolver()).and_then(TcpConnectorFactory::new())
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,12 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.4.2] - 2019-03-30
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fix SIGINT force shutdown
|
||||||
|
|
||||||
|
|
||||||
## [0.4.1] - 2019-03-14
|
## [0.4.1] - 2019-03-14
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-server"
|
name = "actix-server"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix server - General purpose tcp server"
|
description = "Actix server - General purpose tcp server"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
@@ -328,7 +328,7 @@ impl ServerBuilder {
|
|||||||
self.accept.send(Command::Stop);
|
self.accept.send(Command::Stop);
|
||||||
|
|
||||||
// stop workers
|
// stop workers
|
||||||
if !self.workers.is_empty() {
|
if !self.workers.is_empty() && graceful {
|
||||||
spawn(
|
spawn(
|
||||||
futures_unordered(
|
futures_unordered(
|
||||||
self.workers
|
self.workers
|
||||||
|
@@ -6,9 +6,16 @@ use futures::{Async, Future, IntoFuture, Poll};
|
|||||||
use crate::transform_err::{TransformFromErr, TransformMapInitErr};
|
use crate::transform_err::{TransformFromErr, TransformMapInitErr};
|
||||||
use crate::{IntoNewService, NewService, Service};
|
use crate::{IntoNewService, NewService, Service};
|
||||||
|
|
||||||
/// `Transform` service factory.
|
/// The `Transform` trait defines the interface of a Service factory. `Transform`
|
||||||
|
/// is often implemented for middleware, defining how to manufacture a
|
||||||
|
/// middleware Service. A Service that is manufactured by the factory takes
|
||||||
|
/// the Service that follows it during execution as a parameter, assuming
|
||||||
|
/// ownership of the next Service. A Service can be a variety of types, such
|
||||||
|
/// as (but not limited to) another middleware Service, an extractor Service,
|
||||||
|
/// other helper Services, or the request handler endpoint Service.
|
||||||
|
///
|
||||||
|
/// A Service is created by the factory during server initialization.
|
||||||
///
|
///
|
||||||
/// Transform factory creates service that wraps other services.
|
|
||||||
/// `Config` is a service factory configuration type.
|
/// `Config` is a service factory configuration type.
|
||||||
pub trait Transform<S> {
|
pub trait Transform<S> {
|
||||||
/// Requests handled by the service.
|
/// Requests handled by the service.
|
||||||
@@ -33,7 +40,7 @@ pub trait Transform<S> {
|
|||||||
/// The future response value.
|
/// The future response value.
|
||||||
type Future: Future<Item = Self::Transform, Error = Self::InitError>;
|
type Future: Future<Item = Self::Transform, Error = Self::InitError>;
|
||||||
|
|
||||||
/// Create and return a new service value asynchronously.
|
/// Creates and returns a new Service component, asynchronously
|
||||||
fn new_transform(&self, service: S) -> Self::Future;
|
fn new_transform(&self, service: S) -> Self::Future;
|
||||||
|
|
||||||
/// Map this service's factory error to a different error,
|
/// Map this service's factory error to a different error,
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
|
||||||
|
## [0.3.5] - 2019-04-04
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
* Allow to send messages to `FramedTransport` via mpsc channel.
|
* Allow to send messages to `FramedTransport` via mpsc channel.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Remove 'static constraint from Clonable service
|
||||||
|
|
||||||
|
|
||||||
## [0.3.4] - 2019-03-12
|
## [0.3.4] - 2019-03-12
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-utils"
|
name = "actix-utils"
|
||||||
version = "0.3.4"
|
version = "0.3.5"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix utils - various actix net related services"
|
description = "Actix utils - various actix net related services"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
|
@@ -7,12 +7,12 @@ use futures::Poll;
|
|||||||
use super::cell::Cell;
|
use super::cell::Cell;
|
||||||
|
|
||||||
/// Service that allows to turn non-clone service to a service with `Clone` impl
|
/// Service that allows to turn non-clone service to a service with `Clone` impl
|
||||||
pub struct CloneableService<T: 'static> {
|
pub struct CloneableService<T> {
|
||||||
service: Cell<T>,
|
service: Cell<T>,
|
||||||
_t: PhantomData<Rc<()>>,
|
_t: PhantomData<Rc<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> CloneableService<T> {
|
impl<T> CloneableService<T> {
|
||||||
pub fn new(service: T) -> Self
|
pub fn new(service: T) -> Self
|
||||||
where
|
where
|
||||||
T: Service,
|
T: Service,
|
||||||
@@ -24,7 +24,7 @@ impl<T: 'static> CloneableService<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> Clone for CloneableService<T> {
|
impl<T> Clone for CloneableService<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
service: self.service.clone(),
|
service: self.service.clone(),
|
||||||
@@ -35,7 +35,7 @@ impl<T: 'static> Clone for CloneableService<T> {
|
|||||||
|
|
||||||
impl<T> Service for CloneableService<T>
|
impl<T> Service for CloneableService<T>
|
||||||
where
|
where
|
||||||
T: Service + 'static,
|
T: Service,
|
||||||
{
|
{
|
||||||
type Request = T::Request;
|
type Request = T::Request;
|
||||||
type Response = T::Response;
|
type Response = T::Response;
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.1] - 2019-04-03
|
||||||
|
|
||||||
|
* Get dynamic segment by name instead of iterator.
|
||||||
|
|
||||||
## [0.1.0] - 2019-03-09
|
## [0.1.0] - 2019-03-09
|
||||||
|
|
||||||
* Initial release
|
* Initial release
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-router"
|
name = "actix-router"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Path router"
|
description = "Path router"
|
||||||
keywords = ["actix"]
|
keywords = ["actix"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-net.git"
|
repository = "https://github.com/actix/actix-net.git"
|
||||||
documentation = "https://actix.rs/api/actix-net/stable/actix_router/"
|
documentation = "https://docs.rs/actix-router/"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
|
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
workspace = "../"
|
workspace = ".."
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "actix_router"
|
name = "actix_router"
|
||||||
@@ -23,7 +23,8 @@ default = ["http"]
|
|||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
serde = "1.0.80"
|
serde = "1.0.80"
|
||||||
string = "0.1.3"
|
string = "0.2.0"
|
||||||
|
log = "0.4"
|
||||||
http = { version="0.1.14", optional=true }
|
http = { version="0.1.14", optional=true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@@ -196,18 +196,17 @@ impl ResourceDef {
|
|||||||
[PathItem::Static(""); MAX_DYNAMIC_SEGMENTS];
|
[PathItem::Static(""); MAX_DYNAMIC_SEGMENTS];
|
||||||
|
|
||||||
if let Some(captures) = re.captures(path.path()) {
|
if let Some(captures) = re.captures(path.path()) {
|
||||||
let mut passed = false;
|
for (no, name) in names.iter().enumerate() {
|
||||||
|
if let Some(m) = captures.name(&name) {
|
||||||
for capture in captures.iter() {
|
|
||||||
if let Some(ref m) = capture {
|
|
||||||
if !passed {
|
|
||||||
passed = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
segments[idx] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
|
||||||
idx += 1;
|
idx += 1;
|
||||||
pos = m.end();
|
pos = m.end();
|
||||||
|
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||||
|
} else {
|
||||||
|
log::error!(
|
||||||
|
"Dynamic path match but not all segments found: {}",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user