code: public function postDispatch()
      {
          $respond  = false;
          $response = (object) [];
  
          if ($this->_data) {
              $response->data = $this->_data;
          }
  
          if ($this->_errors) {
              $response->errors = $this->_errors;
          }
  
          if ($this->_messages) {
              $response->messages = $this->_messages;
          }
  
          $this
              ->getResponse()
              ->setHeader('Content-Type', 'application/json; charset=utf-8', true)
              ->setBody(json_encode($response, JSON_NUMERIC_CHECK | JSON_HEX_AMP));
      }
docs: Post-dispatch routines.
  
  Common usages for `postDispatch()` include rendering content in a
  sitewide template, link url correction, setting headers, etc.