mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +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.
|
||||
/// 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 {
|
||||
let orig_dir = serve_from.into();
|
||||
let dir = match orig_dir.canonicalize() {
|
||||
|
@ -20,7 +20,6 @@ use crate::{
|
||||
pub struct Response<B> {
|
||||
pub(crate) head: BoxedResponseHead,
|
||||
pub(crate) body: B,
|
||||
pub(crate) error: Option<Error>,
|
||||
}
|
||||
|
||||
impl Response<Body> {
|
||||
@ -30,7 +29,6 @@ impl Response<Body> {
|
||||
Response {
|
||||
head: BoxedResponseHead::new(status),
|
||||
body: Body::Empty,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,11 +70,10 @@ impl Response<Body> {
|
||||
/// Constructs a new response from an error.
|
||||
#[inline]
|
||||
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 {
|
||||
debug!("Internal Server Error: {:?}", error);
|
||||
}
|
||||
resp.error = Some(error);
|
||||
resp
|
||||
}
|
||||
}
|
||||
@ -88,7 +85,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: BoxedResponseHead::new(status),
|
||||
body: body,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,12 +100,6 @@ impl<B> Response<B> {
|
||||
&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.
|
||||
#[inline]
|
||||
pub fn status(&self) -> StatusCode {
|
||||
@ -168,7 +158,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +172,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: self.error,
|
||||
},
|
||||
self.body,
|
||||
)
|
||||
@ -208,7 +196,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: self.error,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,13 +248,8 @@ impl ResponseBuilder {
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
let response = self.head.take().expect("cannot reuse response builder");
|
||||
|
||||
Ok(Response {
|
||||
head: response,
|
||||
body,
|
||||
error: None,
|
||||
})
|
||||
let head = self.head.take().expect("cannot reuse response builder");
|
||||
Ok(Response { head, body })
|
||||
}
|
||||
|
||||
/// Generate response with a streaming body.
|
||||
|
Loading…
Reference in New Issue
Block a user