Daniel Mejia
04/25/2024, 8:29 PMcomponent {
void function onCFCRequest(string cfcname,string method,struct args){
// Request
request.GetJsonRequest = new utils.Request().GetJsonRequest;
// invoke remote cfc
invoke(arguments.cfcname,arguments.method,arguments.args);
return;
}
}
Or
component {
boolean function onApplicationStart(){
application.GetJsonRequest = new utils.Request().GetJsonRequest;
}
void function onCFCRequest(string cfcname,string method,struct args){
// invoke remote cfc
invoke(arguments.cfcname,arguments.method,arguments.args);
return;
}
}seancorfield
utils.Request?Daniel Mejia
04/25/2024, 9:32 PMseancorfield
Daniel Mejia
04/25/2024, 9:35 PMseancorfield
new utils.Request().GetJsonRequest() where you need to call it? (i.e., instead of putting it in a scope and then having your application code reach out to global scopes -- which is bad practice)Daniel Mejia
04/25/2024, 9:42 PMDaniel Mejia
04/25/2024, 9:43 PMDaniel Mejia
04/25/2024, 9:49 PMDaniel Mejia
04/25/2024, 10:06 PMbkbk
04/26/2024, 8:59 AMApplication.GetJsonRequest would then be available to everyone using the application, remote as well as non-remote users. It is poor design - and it can be risky - to expose functionality to the wrong user. In so doing, you would be increasing the vulnerability surface area.
request.GetJsonRequest in onCFCRequest is better. However, you could still improve on this concept.
For example, you could define request.UtilsRequest = new utils.Request(); in onCFCRequest, then call request.UtilsRequest.getJsonRequest() wherever needed. This saves you from changing Application.cfc whenever functionality is added to or removed from Utils.Request.