Skip to content

Instantly share code, notes, and snippets.

@twelverobots
Last active January 2, 2016 12:09
Show Gist options
  • Save twelverobots/8301069 to your computer and use it in GitHub Desktop.
Save twelverobots/8301069 to your computer and use it in GitHub Desktop.
<cfcomponent>
<cffunction name="onCFCRequest" access="public" returntype="any" output="false">
<cfargument name="cfcname" type="string" />
<cfargument name="method" type="string" />
<cfargument name="args" type="struct" />
<cfset var result = "" />
<cfif structKeyExists(URL, "returnFormat") AND NOT listFindNoCase("json,wddx,plain,xml", URL.returnFormat)>
<cfset structDelete(URL, "returnFormat") />
</cfif>
<cfinvoke component="RemoteProxy" method="callMethod" argumentCollection="#arguments#" returnvariable="result" />
<cfreturn result />
</cffunction>
</cfcomponent>
<cfcomponent>
<cffunction name="callMethod" access="remote">
<cfargument name="cfcname" type="string" />
<cfargument name="method" type="string" />
<cfargument name="args" type="struct" />
<cfset var result = "" />
<cfinvoke component="#arguments.cfcname#" method="#arguments.method#" argumentCollection="#arguments.args#" returnvariable="result" />
<cfif structKeyExists(URL, "returnFormat") AND URL.returnFormat EQ "plain">
<cfset result = result.toString() />
</cfif>
<cfreturn result />
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment