in reply to serving a zip file with Dancer2

I can get it to work if I change
return $member->contents;
to this:
return $type =~ /^text/ ? decode_utf8($member->contents) : $member->contents;
But this is really ugly.

What is the proper way to do this?