mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
remove error field from response
This commit is contained in:
parent
900c9e270e
commit
f55e8d7a11
@ -84,7 +84,7 @@ impl Files {
|
|||||||
///
|
///
|
||||||
/// `Files` utilizes the existing Tokio thread-pool for blocking filesystem operations.
|
/// `Files` utilizes the existing Tokio thread-pool for blocking filesystem operations.
|
||||||
/// The number of running threads is adjusted over time as needed, up to a maximum of 512 times
|
/// The number of running threads is adjusted over time as needed, up to a maximum of 512 times
|
||||||
/// the number of server [workers](HttpServer::workers), by default.
|
/// the number of server [workers](actix_web::HttpServer::workers), by default.
|
||||||
pub fn new<T: Into<PathBuf>>(mount_path: &str, serve_from: T) -> Files {
|
pub fn new<T: Into<PathBuf>>(mount_path: &str, serve_from: T) -> Files {
|
||||||
let orig_dir = serve_from.into();
|
let orig_dir = serve_from.into();
|
||||||
let dir = match orig_dir.canonicalize() {
|
let dir = match orig_dir.canonicalize() {
|
||||||
|
@ -20,7 +20,6 @@ use crate::{
|
|||||||
pub struct Response<B> {
|
pub struct Response<B> {
|
||||||
pub(crate) head: BoxedResponseHead,
|
pub(crate) head: BoxedResponseHead,
|
||||||
pub(crate) body: B,
|
pub(crate) body: B,
|
||||||
pub(crate) error: Option<Error>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response<Body> {
|
impl Response<Body> {
|
||||||
@ -30,7 +29,6 @@ impl Response<Body> {
|
|||||||
Response {
|
Response {
|
||||||
head: BoxedResponseHead::new(status),
|
head: BoxedResponseHead::new(status),
|
||||||
body: Body::Empty,
|
body: Body::Empty,
|
||||||
error: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,11 +70,10 @@ impl Response<Body> {
|
|||||||
/// Constructs a new response from an error.
|
/// Constructs a new response from an error.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_error(error: Error) -> Response<Body> {
|
pub fn from_error(error: Error) -> Response<Body> {
|
||||||
let mut resp = error.as_response_error().error_response();
|
let resp = error.as_response_error().error_response();
|
||||||
if resp.head.status == StatusCode::INTERNAL_SERVER_ERROR {
|
if resp.head.status == StatusCode::INTERNAL_SERVER_ERROR {
|
||||||
debug!("Internal Server Error: {:?}", error);
|
debug!("Internal Server Error: {:?}", error);
|
||||||
}
|
}
|
||||||
resp.error = Some(error);
|
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +85,6 @@ impl<B> Response<B> {
|
|||||||
Response {
|
Response {
|
||||||
head: BoxedResponseHead::new(status),
|
head: BoxedResponseHead::new(status),
|
||||||
body: body,
|
body: body,
|
||||||
error: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,12 +100,6 @@ impl<B> Response<B> {
|
|||||||
&mut *self.head
|
&mut *self.head
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the source `error` for this response, if one is set.
|
|
||||||
#[inline]
|
|
||||||
pub fn error(&self) -> Option<&Error> {
|
|
||||||
self.error.as_ref()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the status code of this response.
|
/// Returns the status code of this response.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn status(&self) -> StatusCode {
|
pub fn status(&self) -> StatusCode {
|
||||||
@ -168,7 +158,6 @@ impl<B> Response<B> {
|
|||||||
Response {
|
Response {
|
||||||
head: self.head,
|
head: self.head,
|
||||||
body,
|
body,
|
||||||
error: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +172,6 @@ impl<B> Response<B> {
|
|||||||
Response {
|
Response {
|
||||||
head: self.head,
|
head: self.head,
|
||||||
body,
|
body,
|
||||||
error: self.error,
|
|
||||||
},
|
},
|
||||||
self.body,
|
self.body,
|
||||||
)
|
)
|
||||||
@ -208,7 +196,6 @@ impl<B> Response<B> {
|
|||||||
Response {
|
Response {
|
||||||
head: self.head,
|
head: self.head,
|
||||||
body,
|
body,
|
||||||
error: self.error,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,13 +248,8 @@ impl ResponseBuilder {
|
|||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = self.head.take().expect("cannot reuse response builder");
|
let head = self.head.take().expect("cannot reuse response builder");
|
||||||
|
Ok(Response { head, body })
|
||||||
Ok(Response {
|
|
||||||
head: response,
|
|
||||||
body,
|
|
||||||
error: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate response with a streaming body.
|
/// Generate response with a streaming body.
|
||||||
|
Loading…
Reference in New Issue
Block a user