Skip to content

Instantly share code, notes, and snippets.

@samsonasik
Created May 25, 2017 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsonasik/dca5263d2499ef54e8d687e53cde1f43 to your computer and use it in GitHub Desktop.
Save samsonasik/dca5263d2499ef54e8d687e53cde1f43 to your computer and use it in GitHub Desktop.
fjafjalfjaslfjaslfj
namespace Foo\Middleware;

use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;

class JsonWrappingMiddleware implements MiddlewareInterface
{
    public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $jsonDecodeNextResponse =  json_decode(
            (string) $delegate->process($request)->getBody(),
            true
        );
        $current        = ['c' => 'd'];

        return new JsonResponse(array_merge($jsonDecodeNextResponse, $current));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment