nolanerck
03/24/2023, 12:47 AMjclausen
03/24/2023, 12:53 AMjclausen
03/24/2023, 12:56 AMbdw429s
03/24/2023, 12:58 AMbdw429s
03/24/2023, 12:58 AMWith aroundHandler() turned on, I have to manually call event.renderData() in order to get the JSON back as expected.I'm unclear if you mean an empty around handler, or an around handler which actually invokes the action as required with
arguments.targetAction( argumentCollection=args )
bdw429s
03/24/2023, 12:59 AMnolanerck
03/24/2023, 11:06 PMjclausen
03/25/2023, 1:57 PMaroundHandler
method from coldbox.system.RestHandler
? Because if you are, then you will need to manually replicate the rendering routines that are in the aroundHandler
method of that. See brad’s link above, and mine to the rendering routines in the system.jclausen
03/25/2023, 1:58 PMaroundHandler
method unless you want the outbound payload to be formatted differently.nolanerck
03/25/2023, 7:59 PMfunction aroundHandler ( event, targetAction, eventArguments, rc, prc )
{
event.noLayout();
var args = {
event = arguments.event,
rc = arguments.rc,
prc = arguments.prc
};
if( rc.testBoxAPIToken != application.TESTBOXAPITOKEN )
{
if( !AuthService.isLoggedIn() )
{
try {
throw(type="InvalidCredentials", messages="Not logged in.");
} catch (InvalidCredentials e ) {
}
}
}
structAppend( args, eventArguments );
// execute the action now
return arguments.targetAction( argumentCollection=args );
}
...if I call event.renderData() in my Handler, I do indeed get back JSON, but according to the examples I've read thus far, I shouldn't have to do that since I'm already using event.getResponse().setdata( rslt.data )nolanerck
03/25/2023, 7:59 PMjclausen
03/25/2023, 8:03 PMnolanerck
03/25/2023, 8:07 PMjclausen
03/25/2023, 8:08 PMnolanerck
03/25/2023, 8:11 PMbdw429s
03/26/2023, 3:51 AMnolanerck
03/28/2023, 1:59 AM