perl_help27 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I am trying to return XML data for certain routes in my dancer2 app (depending on a request param). Code below:
However, the send_as is causing an error and not working. If I move the send_as to inside the route, it works. It only gives an exception when placed inside the hook after method. The error is:set serializer => 'JSON'; hook after => sub{ if (request->params->{format} eq 'xml'){ send_as XML => "dsfsdf",{ content_type => 'application/xml; +charset=UTF-8' }; } #else return the response in json format }
Any ideas? Thanks a lot.Exception caught in 'core.app.after_request' filter: Hook error: Can' +t use string ("") as a subroutine ref while "strict refs" in use at / +usr/local/share/perl5/Dancer2/Core/App.pm line 1103. at /usr/local/share/perl5/Dancer2/Core/App.pm line 36. in /usr/local/ +share/perl5/Dancer2/Core/App.pm l. 676
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: send_as from hook after
by Anonymous Monk on Apr 13, 2018 at 19:22 UTC |