library/Benri/Rest/Controller/Action.php
public function preDispatch()
    {
        $error   = null;
        $request = $this->getRequest();

        if (!$request->isGet() && !$request->isHead()) {
            // read data from the request body.
            $this->_input = json_decode($request->getRawBody());

            if (JSON_ERROR_NONE === json_last_error()) {
                return;
            }

            // Sending invalid JSON will result in a `400 Bad Request` response.
            $this
                ->getResponse()
                ->setHttpResponseCode(400)
                ->setHeader('Content-Type', 'text/plain; charset=utf-8', true)
                ->setBody(json_last_error_msg())
                ->sendResponse();

            exit(400);
        }
    }
public function preDispatch()
    {
        $error   = null;
        $request = $this->getRequest();

        if (!$request->isGet() && !$request->isHead()) {
            // read data from the request body.
            $this->_input = json_decode($request->getRawBody());

            if (JSON_ERROR_NONE === json_last_error()) {
                return;
            }

            // Sending invalid JSON will result in a `400 Bad Request` response.
            $this
                ->getResponse()
                ->setHttpResponseCode(400)
                ->setHeader('Content-Type', 'text/plain; charset=utf-8', true)
                ->setBody(json_last_error_msg())
                ->sendResponse();

            exit(400);
        }
    }
Pre-dispatch routines.