Skip to main content

default_problem_responder

Function default_problem_responder 

Source
pub fn default_problem_responder(
    response: Response<TakoBody>,
) -> Response<TakoBody>
Expand description

Default problem-formatter to be installed into Router::error_handler and/or Router::client_error_handler.

Behavior:

  • Successful responses (1xx/2xx/3xx) pass through unchanged so callers may reuse this function as a wrapper without stripping non-error bodies.
  • Error responses (4xx/5xx) that already carry an application/json or application/problem+json Content-Type pass through (the handler produced its own structured error and stays authoritative).
  • Every other error response is rewritten into a Problem document built from the status code, replacing the body and forcing Content-Type: application/problem+json.