aboutsummaryrefslogtreecommitdiffstats
path: root/src/errors.rs
diff options
context:
space:
mode:
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2022-02-05 20:30:47 +0000
committerAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2022-02-05 20:39:25 +0000
commitdd665a4c7e97a8a7513f38ad9293cd8edbe136df (patch)
tree6eb0e3cee4b1355f68e68e9912b7c15b328f4297 /src/errors.rs
parentmerge from jikstra (diff)
downloadminiserve-dd665a4c7e97a8a7513f38ad9293cd8edbe136df.tar.gz
miniserve-dd665a4c7e97a8a7513f38ad9293cd8edbe136df.zip
update to actix-web v4.0-rc.2
Diffstat (limited to '')
-rw-r--r--src/errors.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/errors.rs b/src/errors.rs
index 70bad5c..5f55514 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -109,18 +109,19 @@ impl ResponseError for ContextualError {
}
/// Middleware to convert plain-text error responses to user-friendly web pages
-pub fn error_page_middleware<S>(
+pub fn error_page_middleware<S, B>(
req: ServiceRequest,
srv: &S,
) -> impl Future<Output = actix_web::Result<ServiceResponse>> + 'static
where
- S: Service<ServiceRequest, Response = ServiceResponse, Error = actix_web::Error>,
+ S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
+ B: MessageBody + 'static,
S::Future: 'static,
{
let fut = srv.call(req);
async {
- let res = fut.await?;
+ let res = fut.await?.map_into_boxed_body();
if (res.status().is_client_error() || res.status().is_server_error())
&& res.headers().get(header::CONTENT_TYPE).map(AsRef::as_ref)
@@ -134,7 +135,7 @@ where
}
}
-fn map_error_page<'a>(req: &HttpRequest, head: &mut ResponseHead, body: BoxBody) -> BoxBody {
+fn map_error_page(req: &HttpRequest, head: &mut ResponseHead, body: BoxBody) -> BoxBody {
let error_msg = match body.try_into_bytes() {
Ok(bytes) => bytes,
Err(body) => return body,