public function receive(DispatcherRequestInterface $request)
    {
        if($request->getContentType() == 'application/x-www-form-urlencoded')
        {
            if (in_array($request->getMethod(), array('PUT', 'DELETE', 'PATCH')))
            {
                parse_str($request->getContent(), $data);
                $request->getData()->add($data);
            }
        }

        if(in_array($request->getContentType(), array('application/json', 'application/x-json', 'application/vnd.api+json')))
        {
            if(in_array($request->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')))
            {
                $data = array();

                if ($content = $request->getContent()) {
                    $data = json_decode($content, true);
                }

                if ($data) {
                    $request->getData()->add($data);
                }

                // Transform the JSON API request payloads
                if($request->getContentType() == 'application/vnd.api+json')
                {
                    if (is_array($request->data->data))
                    {
                        $data = $request->data->data;

                        if (isset($data['attributes']) && is_array($data['attributes'])) {
                            $request->data->add($data['attributes']);
                        }
                    }
                }
            }
        }
    }