Esempio n. 1
0
function json(Slim\Http\Response $res, $json = array(), $status = null)
{
    $res->headers->set('Content-Type', 'application/json');
    $res->write(json_encode($json));
    if ($status) {
        $res->setStatus($status);
    }
    return;
}
Esempio n. 2
0
 /**
  * Test finalize
  */
 public function testFinalizeWithoutBody()
 {
     $r = new \Slim\Http\Response();
     $r->status(204);
     $r['Content-Type'] = 'application/json';
     $r->write('Foo');
     $result = $r->finalize();
     $this->assertEquals(3, count($result));
     $this->assertEquals('', $result[2]);
 }