<?php
namespace ShinyGeoip\Responder;

use ShinyGeoip\Core\Responder;

class ApiRequestResponder extends Responder
{
    /**
     * Echos short version of record as json encodes string.
     */
    public function short()
    {
        $this->setContentTypeHeader('json');
        $record = $this->get('record');
        echo json_encode($record);
    }

    /**
     * Echos the full record as json encoded string.
     */
    public function full()
    {
        $this->setContentTypeHeader('json');
        $record = $this->get('record')->jsonSerialize();
        echo json_encode($record);
    }

    /**
     * Echos a json encoded not found error message.
     */
    public function notFound()
    {
        $this->setContentTypeHeader('json');
        echo json_encode(['type' => 'error', 'msg' => 'No record found.']);
    }
}

<?php
namespace ShinyGeoip\Responder;

use ShinyGeoip\Core\Responder;

class ApiRequestResponder extends Responder
{
    /**
     * Echos short version of record as json encodes string.
     */
    public function short()
    {
        $this->setContentTypeHeader('json');
        $record = $this->get('record');
        echo json_encode($record);
        exit;
    }

    /**
     * Echos the full record as json encoded string.
     */
    public function full()
    {
        $this->setContentTypeHeader('json');
        $record = $this->get('record')->jsonSerialize();
        echo json_encode($record);
        exit;
    }

    /**
     * Echos a json encoded not found error message.
     */
    public function notFound()
    {
        $this->setContentTypeHeader('json');
        echo json_encode(['type' => 'error', 'msg' => 'No record found.']);
        exit;
    }
}

Stop script execution after output of json-data so content type header is correct.
Stop script execution after output of json-data so content type header is correct.
