[dancer-users] Automatic JSON serializer breaks error page
Warren Young
warren at etr-usa.com
Fri Mar 14 23:22:09 GMT 2014
On 3/13/2014 19:16, Yanick Champoux wrote:
> On 14-03-13 08:57 PM, Warren Young wrote:
>> Is there a way I can fix this without going back to manual JSON encoding?
>
> My first thought is: do something with the 'before_serializer' hook.
While Lee's solution works for me, it would be nice if Dancer would let
me restrict the automatic serializer to a route prefix:
serializer:
format: JSON
prefix: /api
That would entirely replace Lee's solution.
This wouldn't break backwards compatibility. If you give 'serializer' a
scalar, it can use its current global behavior.
Passing an array of hashes instead of a hash could allow different
serializers for different parts of your route scheme:
serializer:
- format: JSON
prefix: /api
- format: Data::Dumper
prefix: /debug
More information about the dancer-users
mailing list