mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
remove Context::actor() method
This commit is contained in:
parent
e4443226f6
commit
33050f55a3
@ -104,24 +104,29 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
/// Create a new HTTP Context from a request and an actor
|
/// Create a new HTTP Context from a request and an actor
|
||||||
pub fn new(req: HttpRequest<S>, actor: A) -> HttpContext<A, S> {
|
pub fn new(req: HttpRequest<S>, actor: A) -> HttpContext<A, S> {
|
||||||
HttpContext::from_request(req).actor(actor)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new HTTP Context from a request
|
|
||||||
pub fn from_request(req: HttpRequest<S>) -> HttpContext<A, S> {
|
|
||||||
HttpContext {
|
HttpContext {
|
||||||
inner: ContextImpl::new(None),
|
inner: ContextImpl::new(Some(actor)),
|
||||||
stream: None,
|
stream: None,
|
||||||
request: req,
|
request: req,
|
||||||
disconnected: false,
|
disconnected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
/// Create a new HTTP Context
|
||||||
/// Set the actor of this context
|
pub fn with_factory<F>(req: HttpRequest<S>, f: F) -> HttpContext<A, S>
|
||||||
pub fn actor(mut self, actor: A) -> HttpContext<A, S> {
|
where
|
||||||
self.inner.set_actor(actor);
|
F: FnOnce(&mut Self) -> A + 'static,
|
||||||
self
|
{
|
||||||
|
let mut ctx = HttpContext {
|
||||||
|
inner: ContextImpl::new(None),
|
||||||
|
stream: None,
|
||||||
|
request: req,
|
||||||
|
disconnected: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let act = f(&mut ctx);
|
||||||
|
ctx.inner.set_actor(act);
|
||||||
|
ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,24 +88,29 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
/// Create a new Websocket context from a request and an actor
|
/// Create a new Websocket context from a request and an actor
|
||||||
pub fn new(req: HttpRequest<S>, actor: A) -> WebsocketContext<A, S> {
|
pub fn new(req: HttpRequest<S>, actor: A) -> WebsocketContext<A, S> {
|
||||||
WebsocketContext::from_request(req).actor(actor)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new Websocket context from a request
|
|
||||||
pub fn from_request(req: HttpRequest<S>) -> WebsocketContext<A, S> {
|
|
||||||
WebsocketContext {
|
WebsocketContext {
|
||||||
inner: ContextImpl::new(None),
|
inner: ContextImpl::new(Some(actor)),
|
||||||
stream: None,
|
stream: None,
|
||||||
request: req,
|
request: req,
|
||||||
disconnected: false,
|
disconnected: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
/// Create a new Websocket context
|
||||||
/// Set actor for this execution context
|
pub fn with_factory<F>(req: HttpRequest<S>, f: F) -> Self
|
||||||
pub fn actor(mut self, actor: A) -> WebsocketContext<A, S> {
|
where
|
||||||
self.inner.set_actor(actor);
|
F: FnOnce(&mut Self) -> A + 'static,
|
||||||
self
|
{
|
||||||
|
let mut ctx = WebsocketContext {
|
||||||
|
inner: ContextImpl::new(None),
|
||||||
|
stream: None,
|
||||||
|
request: req,
|
||||||
|
disconnected: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let act = f(&mut ctx);
|
||||||
|
ctx.inner.set_actor(act);
|
||||||
|
ctx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user