<?php

namespace RCatlin\Blog\Behavior;

use Assert\Assertion;
use Refinery29\ApiOutput\Resource\ResourceFactory;
use Refinery29\Piston\Response;

trait RenderResponse
{
    /**
     * @param Response $response
     * @param array    $result
     * @param int      $status
     *
     * @return Response
     */
    public function renderResult(Response $response, array $result, $status = 200)
    {
        Assertion::integer($status);

        $response->setResult(
            ResourceFactory::result($result)
        );

        return $response
            ->withHeader('Content-Type', 'application/json')
            ->withStatus($status)
        ;
    }
}

<?php

namespace RCatlin\Blog\Behavior;

use Refinery29\ApiOutput\Resource\ResourceFactory;
use Refinery29\Piston\Response;

trait RenderResponse
{
    /**
     * @param Response $response
     * @param array    $result
     *
     * @return Response
     */
    public function renderResult(Response $response, array $result)
    {
        $response->setStatusCode(200);
        $response->setResult(
            ResourceFactory::result($result)
        );

        return $response->withHeader('Content-Type', 'application/json');
    }
}

--- 
+++ 
@@ -2,6 +2,7 @@
 
 namespace RCatlin\Blog\Behavior;
 
+use Assert\Assertion;
 use Refinery29\ApiOutput\Resource\ResourceFactory;
 use Refinery29\Piston\Response;
 
@@ -10,16 +11,21 @@
     /**
      * @param Response $response
      * @param array    $result
+     * @param int      $status
      *
      * @return Response
      */
-    public function renderResult(Response $response, array $result)
+    public function renderResult(Response $response, array $result, $status = 200)
     {
-        $response->setStatusCode(200);
+        Assertion::integer($status);
+
         $response->setResult(
             ResourceFactory::result($result)
         );
 
-        return $response->withHeader('Content-Type', 'application/json');
+        return $response
+            ->withHeader('Content-Type', 'application/json')
+            ->withStatus($status)
+        ;
     }
 }
Fix Rendering Response with Status Code
