Skip to content

Question: how to implement custom error handler for 404 not found #2564

Answered by robjtede
CSRaghunandan asked this question in Q&A
Discussion options

You must be logged in to vote
let (req, res) = res.into_parts();
let res = res.set_body(r#"{"json", "in the body"}"#.to_owned());

let res = ServiceResponse::new(req, res)
    .map_into_boxed_body()
    .map_into_right_body();

Ok(ErrorHandlerResponse::Response(res))

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CSRaghunandan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2563 on January 03, 2022 13:15.