workaround for Swagger plugin weird response body

This commit is contained in:
Oliver Gorwits
2018-12-31 18:14:42 +00:00
parent 1a66dcccea
commit 32ba1a6b45
2 changed files with 7 additions and 2 deletions

View File

@@ -184,6 +184,12 @@ hook 'before_template' => sub {
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');
}
if ($r->content_type and $r->content_type eq 'text/comma-separated-values') {
my @newlines = ();
my @lines = split m/\n/, $r->content;