perl_help27 has asked for the wisdom of the Perl Monks concerning the following question:
Hello again, I am trying to switch between json and xml serializers in my Dancer2 app. Like change my serializer dynamically in my app. This is my code:
hook before => sub { set serializer => ( request->params->{format} eq 'xml' ? 'XML' : ' +JSON'); };
However, the first request always operates based on the old serializer so I have to call the request twice in a row to get the response using the correct serializer. If you can please help me with that. Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: change serializer in Dancer2 according to request param
by Anonymous Monk on Apr 12, 2018 at 16:56 UTC | |
by perl_help27 (Acolyte) on Apr 12, 2018 at 17:51 UTC | |
by Anonymous Monk on Apr 13, 2018 at 02:34 UTC |