clean up subs

This commit is contained in:
Oliver Gorwits
2019-01-01 10:41:33 +00:00
parent f56c48b83d
commit 3b0a9f6310
2 changed files with 9 additions and 4 deletions

View File

@@ -188,16 +188,20 @@ hook 'before_template' => sub {
$Template::Stash::PRIVATE = undef;
};
# remove empty lines from CSV response
# this makes writing templates much more straightforward!
# workaround for Swagger plugin weird response body
hook 'after' => sub {
my $r = shift; # a Dancer::Response
# workaround for Swagger plugin weird response body
if (request->path eq '/swagger.json') {
$r->content( to_json( $r->content ) );
header('Content-Type' => 'application/json');
}
};
# remove empty lines from CSV response
# this makes writing templates much more straightforward!
hook 'after' => sub {
my $r = shift; # a Dancer::Response
if ($r->content_type and $r->content_type eq 'text/comma-separated-values') {
my @newlines = ();