public function answer($json = null, $corsPreflight = false)
    {
        $answer = new HTTPResponse();

        //set response body
        if (!$corsPreflight) {
            $answer->setBody($json);
        }

        //set CORS if needed
        $answer = $this->setAnswerCORS($answer);

        $answer->addHeader('Content-Type', $this->serializer->getcontentType());

        // save controller's response then return/output
        $this->response = $answer;

        return $answer;
    }
public function answer($json = null, $corsPreflight = false)
    {
        $answer = new HTTPResponse();

        //set response body
        if (!$corsPreflight) {
            $answer->setBody($json);
        }

        //set CORS if needed
        $answer = $this->setAnswerCORS($answer);

        $answer->addHeader('Content-Type', $this->serializer->getcontentType());

        // save controller's response then return/output
        $this->response = $answer;

        return $answer;
    }
public function answer ( $ json = null , $ corsPreflight = false ) { $ answer = new HTTPResponse ( ) ; //set response body if ( ! $ corsPreflight ) { $ answer -> setBody ( $ json ) ; } //set CORS if needed $ answer = $ this -> setAnswerCORS ( $ answer ) ; $ answer -> addHeader ( 'Content-Type' , $ this -> serializer -> getcontentType ( ) ) ; // save controller's response then return/output $ this -> response = $ answer ; return $ answer ; }
Output the API response to client
then exit.

@param  string $json Response body
@param  boolean $corsPreflight Set to true if this is a XHR preflight request answer. CORS shoud be enabled.
@return HTTPResponse
Output the API response to client then exit .