How to overwrite request in SLIM 4

We are trying to create a new custom function in REQUEST.
We only have a slim 3 code for response:
Response Class:
<?php
class ResponseHandler extends \Slim\Psr7\Response
{

    private $data;

    public function getData()
    {
        return $this->data;
    }
    public function withData($data)
    {
        $clone = clone $this;
        $clone->data = $data;
        return $clone;
    }
}

In container:
$container->set('response', function ($container) {
    $headers = new \Slim\Http\Headers(['Content-Type' => 'application/json; charset=UTF-8']);
    $response = new ResponseHandler(200, $headers);

    return $response->withProtocolVersion($container->get('settings')['httpVersion']);
});

And we can use it normally:
return $response->withData([
‘id’ => $this->get_id($mdl),
‘message’ => ‘Salvo com sucesso’
]);