Closed beykery closed 5 years ago
thank , as the test.rs :
res.take_body().take_body() .fold(BytesMut::new(), move |mut body, chunk| { body.extend_from_slice(&chunk); Ok::<_, Error>(body) });
but it result in :
error[E0599]: no method named fold
found for type actix_http::body::ResponseBody<B>
in the current scope
use futures::Stream;
sorry it dont work as bellow :
` use actix_web::{get, middleware, web, App, HttpRequest, HttpResponse, HttpServer, dev, http, Result, Error}; use actix_web::middleware::errhandlers::ErrorHandlerResponse; use serde::{Serialize, Deserialize}; use actix_web::dev::ServiceResponse; use actix_http::http::StatusCode; use actix_http::Response; use actix_web::web::BytesMut; use futures::Stream;
pub fn render_500(mut res: dev::ServiceResponse) -> Result<ErrorHandlerResponse> { res.take_body() .fold(BytesMut::new(), move |mut body, chunk| { body.extend_fromslice(&chunk); Ok::<, Error>(body) }); Ok(ErrorHandlerResponse::Response(res)) } `
error[E0599]: no method named fold
found for type actix_http::body::ResponseBody<B>
in the current scope
You may need to add B: MessageBody
https://github.com/actix/actix-web/blob/master/actix-http/src/body.rs#L104
i can't get it .
I can't get it too.
i use
middleware::errhandlers::ErrorHandlers::new().handler(http::StatusCode::INTERNAL_SERVER_ERROR, errhandle::render_500)
for processing the error 500 in my application as the example in errhandlers.rs
how can i modify the response body ? the example just modify a response header .