Skip to content

Commit

Permalink
add View::JSON#status_code_header
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Nov 20, 2013
1 parent 9e7e306 commit bea5daa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Ark/View/JSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ has json_dumper => (
);

has status_code_field => (
is => 'rw',
is => 'ro',
isa => "Str",
);

has status_code_header => (
is => 'ro',
isa => "Str",
default => 'X-API-Status',
);

# steal code from Catalyst::View::JSON
sub process {
my ($self, $c) = @_;
Expand Down Expand Up @@ -89,7 +95,7 @@ sub process {

if (defined (my $status_code_field = $self->status_code_field)) {
if (exists $data->{$status_code_field}) {
$c->res->header('X-API-Status' => $data->{$status_code_field});
$c->res->header($self->status_code_header => $data->{$status_code_field});
}
}

Expand Down

0 comments on commit bea5daa

Please sign in to comment.