mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 11:31:09 +00:00
remove deprecated on_connect methods (#1857)
This commit is contained in:
parent
8c9ea43e23
commit
093d3a6c59
11 changed files with 8 additions and 146 deletions
|
@ -4,6 +4,13 @@
|
||||||
### Changed
|
### Changed
|
||||||
* Bumped `rand` to `0.8`
|
* Bumped `rand` to `0.8`
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* Deprecated `on_connect` methods have been removed. Prefer the new
|
||||||
|
`on_connect_ext` technique. [#1857]
|
||||||
|
|
||||||
|
[#1857]: https://github.com/actix/actix-web/pull/1857
|
||||||
|
|
||||||
|
|
||||||
## 2.2.0 - 2020-11-25
|
## 2.2.0 - 2020-11-25
|
||||||
### Added
|
### Added
|
||||||
* HttpResponse builders for 1xx status codes. [#1768]
|
* HttpResponse builders for 1xx status codes. [#1768]
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::config::{KeepAlive, ServiceConfig};
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::h1::{Codec, ExpectHandler, H1Service, UpgradeHandler};
|
use crate::h1::{Codec, ExpectHandler, H1Service, UpgradeHandler};
|
||||||
use crate::h2::H2Service;
|
use crate::h2::H2Service;
|
||||||
use crate::helpers::{Data, DataFactory};
|
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::service::HttpService;
|
use crate::service::HttpService;
|
||||||
|
@ -28,8 +27,6 @@ pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler<T>> {
|
||||||
local_addr: Option<net::SocketAddr>,
|
local_addr: Option<net::SocketAddr>,
|
||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
// DEPRECATED: in favor of on_connect_ext
|
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, S)>,
|
_t: PhantomData<(T, S)>,
|
||||||
}
|
}
|
||||||
|
@ -51,7 +48,6 @@ where
|
||||||
local_addr: None,
|
local_addr: None,
|
||||||
expect: ExpectHandler,
|
expect: ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: None,
|
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -141,7 +137,6 @@ where
|
||||||
local_addr: self.local_addr,
|
local_addr: self.local_addr,
|
||||||
expect: expect.into_factory(),
|
expect: expect.into_factory(),
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -171,26 +166,11 @@ where
|
||||||
local_addr: self.local_addr,
|
local_addr: self.local_addr,
|
||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
upgrade: Some(upgrade.into_factory()),
|
upgrade: Some(upgrade.into_factory()),
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set on-connect callback.
|
|
||||||
///
|
|
||||||
/// Called once per connection. Return value of the call is stored in request extensions.
|
|
||||||
///
|
|
||||||
/// *SOFT DEPRECATED*: Prefer the `on_connect_ext` style callback.
|
|
||||||
pub fn on_connect<F, I>(mut self, f: F) -> Self
|
|
||||||
where
|
|
||||||
F: Fn(&T) -> I + 'static,
|
|
||||||
I: Clone + 'static,
|
|
||||||
{
|
|
||||||
self.on_connect = Some(Rc::new(move |io| Box::new(Data(f(io)))));
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the callback to be run on connection establishment.
|
/// Sets the callback to be run on connection establishment.
|
||||||
///
|
///
|
||||||
/// Has mutable access to a data container that will be merged into request extensions.
|
/// Has mutable access to a data container that will be merged into request extensions.
|
||||||
|
@ -224,7 +204,6 @@ where
|
||||||
H1Service::with_config(cfg, service.into_factory())
|
H1Service::with_config(cfg, service.into_factory())
|
||||||
.expect(self.expect)
|
.expect(self.expect)
|
||||||
.upgrade(self.upgrade)
|
.upgrade(self.upgrade)
|
||||||
.on_connect(self.on_connect)
|
|
||||||
.on_connect_ext(self.on_connect_ext)
|
.on_connect_ext(self.on_connect_ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +226,6 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
H2Service::with_config(cfg, service.into_factory())
|
H2Service::with_config(cfg, service.into_factory())
|
||||||
.on_connect(self.on_connect)
|
|
||||||
.on_connect_ext(self.on_connect_ext)
|
.on_connect_ext(self.on_connect_ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +250,6 @@ where
|
||||||
HttpService::with_config(cfg, service.into_factory())
|
HttpService::with_config(cfg, service.into_factory())
|
||||||
.expect(self.expect)
|
.expect(self.expect)
|
||||||
.upgrade(self.upgrade)
|
.upgrade(self.upgrade)
|
||||||
.on_connect(self.on_connect)
|
|
||||||
.on_connect_ext(self.on_connect_ext)
|
.on_connect_ext(self.on_connect_ext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
actix-http/src/clinu/mod.rs
Normal file
0
actix-http/src/clinu/mod.rs
Normal file
|
@ -19,7 +19,6 @@ use crate::cloneable::CloneableService;
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::error::{ParseError, PayloadError};
|
use crate::error::{ParseError, PayloadError};
|
||||||
use crate::helpers::DataFactory;
|
|
||||||
use crate::httpmessage::HttpMessage;
|
use crate::httpmessage::HttpMessage;
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
|
@ -96,7 +95,6 @@ where
|
||||||
service: CloneableService<S>,
|
service: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
on_connect: Option<Box<dyn DataFactory>>,
|
|
||||||
on_connect_data: Extensions,
|
on_connect_data: Extensions,
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
|
@ -184,7 +182,6 @@ where
|
||||||
service: CloneableService<S>,
|
service: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
on_connect: Option<Box<dyn DataFactory>>,
|
|
||||||
on_connect_data: Extensions,
|
on_connect_data: Extensions,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -197,7 +194,6 @@ where
|
||||||
service,
|
service,
|
||||||
expect,
|
expect,
|
||||||
upgrade,
|
upgrade,
|
||||||
on_connect,
|
|
||||||
on_connect_data,
|
on_connect_data,
|
||||||
peer_addr,
|
peer_addr,
|
||||||
)
|
)
|
||||||
|
@ -213,7 +209,6 @@ where
|
||||||
service: CloneableService<S>,
|
service: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
on_connect: Option<Box<dyn DataFactory>>,
|
|
||||||
on_connect_data: Extensions,
|
on_connect_data: Extensions,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -246,7 +241,6 @@ where
|
||||||
service,
|
service,
|
||||||
expect,
|
expect,
|
||||||
upgrade,
|
upgrade,
|
||||||
on_connect,
|
|
||||||
on_connect_data,
|
on_connect_data,
|
||||||
flags,
|
flags,
|
||||||
peer_addr,
|
peer_addr,
|
||||||
|
@ -572,12 +566,6 @@ where
|
||||||
let pl = this.codec.message_type();
|
let pl = this.codec.message_type();
|
||||||
req.head_mut().peer_addr = *this.peer_addr;
|
req.head_mut().peer_addr = *this.peer_addr;
|
||||||
|
|
||||||
// DEPRECATED
|
|
||||||
// set on_connect data
|
|
||||||
if let Some(ref on_connect) = this.on_connect {
|
|
||||||
on_connect.set(&mut req.extensions_mut());
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge on_connect_ext data into request extensions
|
// merge on_connect_ext data into request extensions
|
||||||
req.extensions_mut().drain_from(this.on_connect_data);
|
req.extensions_mut().drain_from(this.on_connect_data);
|
||||||
|
|
||||||
|
@ -1038,7 +1026,6 @@ mod tests {
|
||||||
CloneableService::new(ok_service()),
|
CloneableService::new(ok_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1079,7 +1066,6 @@ mod tests {
|
||||||
CloneableService::new(echo_path_service()),
|
CloneableService::new(echo_path_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1134,7 +1120,6 @@ mod tests {
|
||||||
CloneableService::new(echo_path_service()),
|
CloneableService::new(echo_path_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1184,7 +1169,6 @@ mod tests {
|
||||||
CloneableService::new(echo_payload_service()),
|
CloneableService::new(echo_payload_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1256,7 +1240,6 @@ mod tests {
|
||||||
CloneableService::new(echo_path_service()),
|
CloneableService::new(echo_path_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1316,7 +1299,6 @@ mod tests {
|
||||||
CloneableService::new(ok_service()),
|
CloneableService::new(ok_service()),
|
||||||
CloneableService::new(ExpectHandler),
|
CloneableService::new(ExpectHandler),
|
||||||
Some(CloneableService::new(UpgradeHandler(PhantomData))),
|
Some(CloneableService::new(UpgradeHandler(PhantomData))),
|
||||||
None,
|
|
||||||
Extensions::new(),
|
Extensions::new(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,7 +15,6 @@ use crate::body::MessageBody;
|
||||||
use crate::cloneable::CloneableService;
|
use crate::cloneable::CloneableService;
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::helpers::DataFactory;
|
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::{ConnectCallback, Extensions};
|
use crate::{ConnectCallback, Extensions};
|
||||||
|
@ -30,7 +29,6 @@ pub struct H1Service<T, S, B, X = ExpectHandler, U = UpgradeHandler<T>> {
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
@ -53,7 +51,6 @@ where
|
||||||
srv: service.into_factory(),
|
srv: service.into_factory(),
|
||||||
expect: ExpectHandler,
|
expect: ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: None,
|
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -215,7 +212,6 @@ where
|
||||||
cfg: self.cfg,
|
cfg: self.cfg,
|
||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -232,21 +228,11 @@ where
|
||||||
cfg: self.cfg,
|
cfg: self.cfg,
|
||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set on connect callback.
|
|
||||||
pub(crate) fn on_connect(
|
|
||||||
mut self,
|
|
||||||
f: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
) -> Self {
|
|
||||||
self.on_connect = f;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set on connect callback.
|
/// Set on connect callback.
|
||||||
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
||||||
self.on_connect_ext = f;
|
self.on_connect_ext = f;
|
||||||
|
@ -284,7 +270,6 @@ where
|
||||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
||||||
expect: None,
|
expect: None,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: self.on_connect.clone(),
|
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
cfg: Some(self.cfg.clone()),
|
cfg: Some(self.cfg.clone()),
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
|
@ -314,7 +299,6 @@ where
|
||||||
fut_upg: Option<U::Future>,
|
fut_upg: Option<U::Future>,
|
||||||
expect: Option<X::Service>,
|
expect: Option<X::Service>,
|
||||||
upgrade: Option<U::Service>,
|
upgrade: Option<U::Service>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: Option<ServiceConfig>,
|
cfg: Option<ServiceConfig>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
|
@ -371,7 +355,6 @@ where
|
||||||
service,
|
service,
|
||||||
this.expect.take().unwrap(),
|
this.expect.take().unwrap(),
|
||||||
this.upgrade.take(),
|
this.upgrade.take(),
|
||||||
this.on_connect.clone(),
|
|
||||||
this.on_connect_ext.clone(),
|
this.on_connect_ext.clone(),
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
@ -383,7 +366,6 @@ pub struct H1ServiceHandler<T, S: Service, B, X: Service, U: Service> {
|
||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
|
@ -405,7 +387,6 @@ where
|
||||||
srv: S,
|
srv: S,
|
||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
) -> H1ServiceHandler<T, S, B, X, U> {
|
) -> H1ServiceHandler<T, S, B, X, U> {
|
||||||
H1ServiceHandler {
|
H1ServiceHandler {
|
||||||
|
@ -413,7 +394,6 @@ where
|
||||||
expect: CloneableService::new(expect),
|
expect: CloneableService::new(expect),
|
||||||
upgrade: upgrade.map(CloneableService::new),
|
upgrade: upgrade.map(CloneableService::new),
|
||||||
cfg,
|
cfg,
|
||||||
on_connect,
|
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -480,8 +460,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, (io, addr): Self::Request) -> Self::Future {
|
fn call(&mut self, (io, addr): Self::Request) -> Self::Future {
|
||||||
let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
|
|
||||||
|
|
||||||
let mut connect_extensions = Extensions::new();
|
let mut connect_extensions = Extensions::new();
|
||||||
if let Some(ref handler) = self.on_connect_ext {
|
if let Some(ref handler) = self.on_connect_ext {
|
||||||
// run on_connect_ext callback, populating connect extensions
|
// run on_connect_ext callback, populating connect extensions
|
||||||
|
@ -494,7 +472,6 @@ where
|
||||||
self.srv.clone(),
|
self.srv.clone(),
|
||||||
self.expect.clone(),
|
self.expect.clone(),
|
||||||
self.upgrade.clone(),
|
self.upgrade.clone(),
|
||||||
deprecated_on_connect,
|
|
||||||
connect_extensions,
|
connect_extensions,
|
||||||
addr,
|
addr,
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,6 @@ use crate::body::{BodySize, MessageBody, ResponseBody};
|
||||||
use crate::cloneable::CloneableService;
|
use crate::cloneable::CloneableService;
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::helpers::DataFactory;
|
|
||||||
use crate::httpmessage::HttpMessage;
|
use crate::httpmessage::HttpMessage;
|
||||||
use crate::message::ResponseHead;
|
use crate::message::ResponseHead;
|
||||||
use crate::payload::Payload;
|
use crate::payload::Payload;
|
||||||
|
@ -36,7 +35,6 @@ where
|
||||||
{
|
{
|
||||||
service: CloneableService<S>,
|
service: CloneableService<S>,
|
||||||
connection: Connection<T, Bytes>,
|
connection: Connection<T, Bytes>,
|
||||||
on_connect: Option<Box<dyn DataFactory>>,
|
|
||||||
on_connect_data: Extensions,
|
on_connect_data: Extensions,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
|
@ -57,7 +55,6 @@ where
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
service: CloneableService<S>,
|
service: CloneableService<S>,
|
||||||
connection: Connection<T, Bytes>,
|
connection: Connection<T, Bytes>,
|
||||||
on_connect: Option<Box<dyn DataFactory>>,
|
|
||||||
on_connect_data: Extensions,
|
on_connect_data: Extensions,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
timeout: Option<Delay>,
|
timeout: Option<Delay>,
|
||||||
|
@ -84,7 +81,6 @@ where
|
||||||
config,
|
config,
|
||||||
peer_addr,
|
peer_addr,
|
||||||
connection,
|
connection,
|
||||||
on_connect,
|
|
||||||
on_connect_data,
|
on_connect_data,
|
||||||
ka_expire,
|
ka_expire,
|
||||||
ka_timer,
|
ka_timer,
|
||||||
|
@ -134,12 +130,6 @@ where
|
||||||
head.headers = parts.headers.into();
|
head.headers = parts.headers.into();
|
||||||
head.peer_addr = this.peer_addr;
|
head.peer_addr = this.peer_addr;
|
||||||
|
|
||||||
// DEPRECATED
|
|
||||||
// set on_connect data
|
|
||||||
if let Some(ref on_connect) = this.on_connect {
|
|
||||||
on_connect.set(&mut req.extensions_mut());
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge on_connect_ext data into request extensions
|
// merge on_connect_ext data into request extensions
|
||||||
req.extensions_mut().drain_from(&mut this.on_connect_data);
|
req.extensions_mut().drain_from(&mut this.on_connect_data);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ use crate::body::MessageBody;
|
||||||
use crate::cloneable::CloneableService;
|
use crate::cloneable::CloneableService;
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::helpers::DataFactory;
|
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::{ConnectCallback, Extensions};
|
use crate::{ConnectCallback, Extensions};
|
||||||
|
@ -31,7 +30,6 @@ use super::dispatcher::Dispatcher;
|
||||||
pub struct H2Service<T, S, B> {
|
pub struct H2Service<T, S, B> {
|
||||||
srv: S,
|
srv: S,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
@ -51,23 +49,12 @@ where
|
||||||
) -> Self {
|
) -> Self {
|
||||||
H2Service {
|
H2Service {
|
||||||
cfg,
|
cfg,
|
||||||
on_connect: None,
|
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
srv: service.into_factory(),
|
srv: service.into_factory(),
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set on connect callback.
|
|
||||||
|
|
||||||
pub(crate) fn on_connect(
|
|
||||||
mut self,
|
|
||||||
f: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
) -> Self {
|
|
||||||
self.on_connect = f;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set on connect callback.
|
/// Set on connect callback.
|
||||||
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
||||||
self.on_connect_ext = f;
|
self.on_connect_ext = f;
|
||||||
|
@ -212,7 +199,6 @@ where
|
||||||
H2ServiceResponse {
|
H2ServiceResponse {
|
||||||
fut: self.srv.new_service(()),
|
fut: self.srv.new_service(()),
|
||||||
cfg: Some(self.cfg.clone()),
|
cfg: Some(self.cfg.clone()),
|
||||||
on_connect: self.on_connect.clone(),
|
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -225,7 +211,6 @@ pub struct H2ServiceResponse<T, S: ServiceFactory, B> {
|
||||||
#[pin]
|
#[pin]
|
||||||
fut: S::Future,
|
fut: S::Future,
|
||||||
cfg: Option<ServiceConfig>,
|
cfg: Option<ServiceConfig>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
@ -248,7 +233,6 @@ where
|
||||||
let this = self.as_mut().project();
|
let this = self.as_mut().project();
|
||||||
H2ServiceHandler::new(
|
H2ServiceHandler::new(
|
||||||
this.cfg.take().unwrap(),
|
this.cfg.take().unwrap(),
|
||||||
this.on_connect.clone(),
|
|
||||||
this.on_connect_ext.clone(),
|
this.on_connect_ext.clone(),
|
||||||
service,
|
service,
|
||||||
)
|
)
|
||||||
|
@ -260,7 +244,6 @@ where
|
||||||
pub struct H2ServiceHandler<T, S: Service, B> {
|
pub struct H2ServiceHandler<T, S: Service, B> {
|
||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
@ -275,13 +258,11 @@ where
|
||||||
{
|
{
|
||||||
fn new(
|
fn new(
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
srv: S,
|
srv: S,
|
||||||
) -> H2ServiceHandler<T, S, B> {
|
) -> H2ServiceHandler<T, S, B> {
|
||||||
H2ServiceHandler {
|
H2ServiceHandler {
|
||||||
cfg,
|
cfg,
|
||||||
on_connect,
|
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
srv: CloneableService::new(srv),
|
srv: CloneableService::new(srv),
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
|
@ -312,8 +293,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, (io, addr): Self::Request) -> Self::Future {
|
fn call(&mut self, (io, addr): Self::Request) -> Self::Future {
|
||||||
let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
|
|
||||||
|
|
||||||
let mut connect_extensions = Extensions::new();
|
let mut connect_extensions = Extensions::new();
|
||||||
if let Some(ref handler) = self.on_connect_ext {
|
if let Some(ref handler) = self.on_connect_ext {
|
||||||
// run on_connect_ext callback, populating connect extensions
|
// run on_connect_ext callback, populating connect extensions
|
||||||
|
@ -325,7 +304,6 @@ where
|
||||||
Some(self.srv.clone()),
|
Some(self.srv.clone()),
|
||||||
Some(self.cfg.clone()),
|
Some(self.cfg.clone()),
|
||||||
addr,
|
addr,
|
||||||
deprecated_on_connect,
|
|
||||||
Some(connect_extensions),
|
Some(connect_extensions),
|
||||||
server::handshake(io),
|
server::handshake(io),
|
||||||
),
|
),
|
||||||
|
@ -343,7 +321,6 @@ where
|
||||||
Option<CloneableService<S>>,
|
Option<CloneableService<S>>,
|
||||||
Option<ServiceConfig>,
|
Option<ServiceConfig>,
|
||||||
Option<net::SocketAddr>,
|
Option<net::SocketAddr>,
|
||||||
Option<Box<dyn DataFactory>>,
|
|
||||||
Option<Extensions>,
|
Option<Extensions>,
|
||||||
Handshake<T, Bytes>,
|
Handshake<T, Bytes>,
|
||||||
),
|
),
|
||||||
|
@ -379,7 +356,6 @@ where
|
||||||
ref mut srv,
|
ref mut srv,
|
||||||
ref mut config,
|
ref mut config,
|
||||||
ref peer_addr,
|
ref peer_addr,
|
||||||
ref mut on_connect,
|
|
||||||
ref mut on_connect_data,
|
ref mut on_connect_data,
|
||||||
ref mut handshake,
|
ref mut handshake,
|
||||||
) => match Pin::new(handshake).poll(cx) {
|
) => match Pin::new(handshake).poll(cx) {
|
||||||
|
@ -387,7 +363,6 @@ where
|
||||||
self.state = State::Incoming(Dispatcher::new(
|
self.state = State::Incoming(Dispatcher::new(
|
||||||
srv.take().unwrap(),
|
srv.take().unwrap(),
|
||||||
conn,
|
conn,
|
||||||
on_connect.take(),
|
|
||||||
on_connect_data.take().unwrap(),
|
on_connect_data.take().unwrap(),
|
||||||
config.take().unwrap(),
|
config.take().unwrap(),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -3,8 +3,6 @@ use std::io;
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
use http::Version;
|
use http::Version;
|
||||||
|
|
||||||
use crate::extensions::Extensions;
|
|
||||||
|
|
||||||
const DIGITS_START: u8 = b'0';
|
const DIGITS_START: u8 = b'0';
|
||||||
|
|
||||||
pub(crate) fn write_status_line(version: Version, n: u16, bytes: &mut BytesMut) {
|
pub(crate) fn write_status_line(version: Version, n: u16, bytes: &mut BytesMut) {
|
||||||
|
@ -56,18 +54,6 @@ impl<'a> io::Write for Writer<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait DataFactory {
|
|
||||||
fn set(&self, ext: &mut Extensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct Data<T>(pub(crate) T);
|
|
||||||
|
|
||||||
impl<T: Clone + 'static> DataFactory for Data<T> {
|
|
||||||
fn set(&self, ext: &mut Extensions) {
|
|
||||||
ext.insert(self.0.clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
|
|
@ -17,7 +17,6 @@ use crate::builder::HttpServiceBuilder;
|
||||||
use crate::cloneable::CloneableService;
|
use crate::cloneable::CloneableService;
|
||||||
use crate::config::{KeepAlive, ServiceConfig};
|
use crate::config::{KeepAlive, ServiceConfig};
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::helpers::DataFactory;
|
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::{h1, h2::Dispatcher, ConnectCallback, Extensions, Protocol};
|
use crate::{h1, h2::Dispatcher, ConnectCallback, Extensions, Protocol};
|
||||||
|
@ -28,8 +27,6 @@ pub struct HttpService<T, S, B, X = h1::ExpectHandler, U = h1::UpgradeHandler<T>
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
// DEPRECATED: in favor of on_connect_ext
|
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
@ -67,7 +64,6 @@ where
|
||||||
srv: service.into_factory(),
|
srv: service.into_factory(),
|
||||||
expect: h1::ExpectHandler,
|
expect: h1::ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: None,
|
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -83,7 +79,6 @@ where
|
||||||
srv: service.into_factory(),
|
srv: service.into_factory(),
|
||||||
expect: h1::ExpectHandler,
|
expect: h1::ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: None,
|
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -116,7 +111,6 @@ where
|
||||||
cfg: self.cfg,
|
cfg: self.cfg,
|
||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
|
@ -142,21 +136,11 @@ where
|
||||||
cfg: self.cfg,
|
cfg: self.cfg,
|
||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
on_connect: self.on_connect,
|
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set on connect callback.
|
|
||||||
pub(crate) fn on_connect(
|
|
||||||
mut self,
|
|
||||||
f: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
) -> Self {
|
|
||||||
self.on_connect = f;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set connect callback with mutable access to request data container.
|
/// Set connect callback with mutable access to request data container.
|
||||||
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
pub(crate) fn on_connect_ext(mut self, f: Option<Rc<ConnectCallback<T>>>) -> Self {
|
||||||
self.on_connect_ext = f;
|
self.on_connect_ext = f;
|
||||||
|
@ -366,7 +350,6 @@ where
|
||||||
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
fut_upg: self.upgrade.as_ref().map(|f| f.new_service(())),
|
||||||
expect: None,
|
expect: None,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect: self.on_connect.clone(),
|
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
cfg: self.cfg.clone(),
|
cfg: self.cfg.clone(),
|
||||||
_t: PhantomData,
|
_t: PhantomData,
|
||||||
|
@ -391,7 +374,6 @@ pub struct HttpServiceResponse<
|
||||||
fut_upg: Option<U::Future>,
|
fut_upg: Option<U::Future>,
|
||||||
expect: Option<X::Service>,
|
expect: Option<X::Service>,
|
||||||
upgrade: Option<U::Service>,
|
upgrade: Option<U::Service>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
_t: PhantomData<(T, B)>,
|
_t: PhantomData<(T, B)>,
|
||||||
|
@ -451,7 +433,6 @@ where
|
||||||
service,
|
service,
|
||||||
this.expect.take().unwrap(),
|
this.expect.take().unwrap(),
|
||||||
this.upgrade.take(),
|
this.upgrade.take(),
|
||||||
this.on_connect.clone(),
|
|
||||||
this.on_connect_ext.clone(),
|
this.on_connect_ext.clone(),
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
@ -464,7 +445,6 @@ pub struct HttpServiceHandler<T, S: Service, B, X: Service, U: Service> {
|
||||||
expect: CloneableService<X>,
|
expect: CloneableService<X>,
|
||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B, X)>,
|
_t: PhantomData<(T, B, X)>,
|
||||||
}
|
}
|
||||||
|
@ -486,12 +466,10 @@ where
|
||||||
srv: S,
|
srv: S,
|
||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect: Option<Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,
|
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
) -> HttpServiceHandler<T, S, B, X, U> {
|
) -> HttpServiceHandler<T, S, B, X, U> {
|
||||||
HttpServiceHandler {
|
HttpServiceHandler {
|
||||||
cfg,
|
cfg,
|
||||||
on_connect,
|
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
srv: CloneableService::new(srv),
|
srv: CloneableService::new(srv),
|
||||||
expect: CloneableService::new(expect),
|
expect: CloneableService::new(expect),
|
||||||
|
@ -564,7 +542,6 @@ where
|
||||||
fn call(&mut self, (io, proto, peer_addr): Self::Request) -> Self::Future {
|
fn call(&mut self, (io, proto, peer_addr): Self::Request) -> Self::Future {
|
||||||
let mut connect_extensions = Extensions::new();
|
let mut connect_extensions = Extensions::new();
|
||||||
|
|
||||||
let deprecated_on_connect = self.on_connect.as_ref().map(|handler| handler(&io));
|
|
||||||
if let Some(ref handler) = self.on_connect_ext {
|
if let Some(ref handler) = self.on_connect_ext {
|
||||||
handler(&io, &mut connect_extensions);
|
handler(&io, &mut connect_extensions);
|
||||||
}
|
}
|
||||||
|
@ -575,7 +552,6 @@ where
|
||||||
server::handshake(io),
|
server::handshake(io),
|
||||||
self.cfg.clone(),
|
self.cfg.clone(),
|
||||||
self.srv.clone(),
|
self.srv.clone(),
|
||||||
deprecated_on_connect,
|
|
||||||
connect_extensions,
|
connect_extensions,
|
||||||
peer_addr,
|
peer_addr,
|
||||||
))),
|
))),
|
||||||
|
@ -588,7 +564,6 @@ where
|
||||||
self.srv.clone(),
|
self.srv.clone(),
|
||||||
self.expect.clone(),
|
self.expect.clone(),
|
||||||
self.upgrade.clone(),
|
self.upgrade.clone(),
|
||||||
deprecated_on_connect,
|
|
||||||
connect_extensions,
|
connect_extensions,
|
||||||
peer_addr,
|
peer_addr,
|
||||||
)),
|
)),
|
||||||
|
@ -617,7 +592,6 @@ where
|
||||||
Handshake<T, Bytes>,
|
Handshake<T, Bytes>,
|
||||||
ServiceConfig,
|
ServiceConfig,
|
||||||
CloneableService<S>,
|
CloneableService<S>,
|
||||||
Option<Box<dyn DataFactory>>,
|
|
||||||
Extensions,
|
Extensions,
|
||||||
Option<net::SocketAddr>,
|
Option<net::SocketAddr>,
|
||||||
)>,
|
)>,
|
||||||
|
@ -694,12 +668,10 @@ where
|
||||||
} else {
|
} else {
|
||||||
panic!()
|
panic!()
|
||||||
};
|
};
|
||||||
let (_, cfg, srv, on_connect, on_connect_data, peer_addr) =
|
let (_, cfg, srv, on_connect_data, peer_addr) = data.take().unwrap();
|
||||||
data.take().unwrap();
|
|
||||||
self.set(State::H2(Dispatcher::new(
|
self.set(State::H2(Dispatcher::new(
|
||||||
srv,
|
srv,
|
||||||
conn,
|
conn,
|
||||||
on_connect,
|
|
||||||
on_connect_data,
|
on_connect_data,
|
||||||
cfg,
|
cfg,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -410,10 +410,8 @@ async fn test_h2_service_error() {
|
||||||
async fn test_h2_on_connect() {
|
async fn test_h2_on_connect() {
|
||||||
let srv = test_server(move || {
|
let srv = test_server(move || {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.on_connect(|_| 10usize)
|
|
||||||
.on_connect_ext(|_, data| data.insert(20isize))
|
.on_connect_ext(|_, data| data.insert(20isize))
|
||||||
.h2(|req: Request| {
|
.h2(|req: Request| {
|
||||||
assert!(req.extensions().contains::<usize>());
|
|
||||||
assert!(req.extensions().contains::<isize>());
|
assert!(req.extensions().contains::<isize>());
|
||||||
ok::<_, ()>(Response::Ok().finish())
|
ok::<_, ()>(Response::Ok().finish())
|
||||||
})
|
})
|
||||||
|
|
|
@ -662,10 +662,8 @@ async fn test_h1_service_error() {
|
||||||
async fn test_h1_on_connect() {
|
async fn test_h1_on_connect() {
|
||||||
let srv = test_server(|| {
|
let srv = test_server(|| {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.on_connect(|_| 10usize)
|
|
||||||
.on_connect_ext(|_, data| data.insert(20isize))
|
.on_connect_ext(|_, data| data.insert(20isize))
|
||||||
.h1(|req: Request| {
|
.h1(|req: Request| {
|
||||||
assert!(req.extensions().contains::<usize>());
|
|
||||||
assert!(req.extensions().contains::<isize>());
|
assert!(req.extensions().contains::<isize>());
|
||||||
future::ok::<_, ()>(Response::Ok().finish())
|
future::ok::<_, ()>(Response::Ok().finish())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue