addFormatter() public static method

Add a response formatter.
public static addFormatter ( string $key, Dingo\Api\Http\Response\Format\Format $formatter ) : void
$key string
$formatter Dingo\Api\Http\Response\Format\Format
return void
 public function testChangingResponseHeadersWithEvents()
 {
     $this->events->listen('Dingo\\Api\\Event\\ResponseIsMorphing', function ($event) {
         $event->response->headers->set('x-foo', 'bar');
     });
     Response::addFormatter('json', new Json());
     $response = new Response(['foo' => 'bar']);
     $this->assertEquals('bar', $response->morph('json')->headers->get('x-foo'));
     $this->events->forget('Dingo\\Api\\Event\\ResponseIsMorphing');
 }