I want to send JSON responses for all types of errors.
I tried to do something like for 404 not found errors, but not sure how to proceed further:
pub fn not_found_error_handler<B>(
mut res: dev::ServiceResponse<B>,
) -> actix_web::Result<middleware::ErrorHandlerResponse<B>> {
let req = res.request();
let res = res.map_body(|_, _| {/* something needs to go here to modify response body to include json */});
Ok(middleware::ErrorHandlerResponse::Response(res))
}
I'm using the latest actix web beta version 18
I want to send JSON responses for all types of errors.
I tried to do something like for 404 not found errors, but not sure how to proceed further:
I'm using the latest actix web beta version 18