mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 09:59:21 +02:00
impl Default trait for HttpRequest
This commit is contained in:
@ -75,13 +75,8 @@ impl HttpRequest<()> {
|
||||
)
|
||||
}
|
||||
|
||||
/// Construct request for error response.
|
||||
pub(crate) fn for_error() -> HttpRequest {
|
||||
HttpRequest(Rc::new(HttpMessage::default()), Rc::new(()))
|
||||
}
|
||||
|
||||
/// Construct new http request with state.
|
||||
pub(crate) fn with_state<S>(self, state: Rc<S>) -> HttpRequest<S> {
|
||||
pub fn with_state<S>(self, state: Rc<S>) -> HttpRequest<S> {
|
||||
HttpRequest(self.0, state)
|
||||
}
|
||||
}
|
||||
@ -345,6 +340,14 @@ impl<S> HttpRequest<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for HttpRequest<()> {
|
||||
|
||||
/// Construct default request
|
||||
fn default() -> HttpRequest {
|
||||
HttpRequest(Rc::new(HttpMessage::default()), Rc::new(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> Clone for HttpRequest<S> {
|
||||
fn clone(&self) -> HttpRequest<S> {
|
||||
HttpRequest(Rc::clone(&self.0), Rc::clone(&self.1))
|
||||
|
@ -39,13 +39,13 @@ impl Pipeline {
|
||||
Pipeline(PipelineState::Starting(res)),
|
||||
Err(err) =>
|
||||
Pipeline(PipelineState::Error(
|
||||
Box::new((Task::reply(err), HttpRequest::for_error()))))
|
||||
Box::new((Task::reply(err), HttpRequest::default()))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error<R: Into<HttpResponse>>(resp: R) -> Self {
|
||||
Pipeline(PipelineState::Error(Box::new((Task::reply(resp), HttpRequest::for_error()))))
|
||||
Pipeline(PipelineState::Error(Box::new((Task::reply(resp), HttpRequest::default()))))
|
||||
}
|
||||
|
||||
pub(crate) fn disconnected(&mut self) {
|
||||
@ -79,7 +79,7 @@ impl Pipeline {
|
||||
self.0 = PipelineState::Handle(h),
|
||||
Err(err) =>
|
||||
self.0 = PipelineState::Error(
|
||||
Box::new((Task::reply(err), HttpRequest::for_error())))
|
||||
Box::new((Task::reply(err), HttpRequest::default())))
|
||||
}
|
||||
}
|
||||
PipelineState::Handle(mut st) => {
|
||||
|
Reference in New Issue
Block a user