package API::Response;

use strict;
use warnings;

use Apache2::Const qw(OK);
use JSON::XS;

use lib '/app/tools/common/lib';
use Common::Assert;

use RSApache::Response;
use base 'RSApache::Response::JSON';

sub respond {
    my ( $self, $apache ) = @_;

    $apache->content_type("application/json; charset=UTF-8");

    # Instruct the browser (specifically, Internet Explorer) to NOT CACHE this response
    #
    $apache->header_out( 'Cache-Control' => 'no-cache' );
    $apache->header_out( 'Pragma'        => 'no-cache' );
    $apache->header_out( 'Expires'       => '-1' );

    $apache->send_http_header();
    print $self->{output};

    if( defined $self->{status_code} ) {
        $apache->status( $self->{status_code} );
    }

    return OK;
}

###
1;    # Play nicely.
###

