I was talking to someone recently about REST and ColdFusion 10 (something I'd like to demo here soon) and the question of HTTP methods came up. One of the interesting things ColdFusion 10's REST support allows for is CFC methods locked down to a particular HTTP request type. This allows you to ensure a method is run only for a GET request, or PUT, or whatever makes sense for your business logic.But what about ColdFusion 9, and earlier? Is it possible to programatically respond to different request types? Absolutely. You've got not one, but two different ways to check how the current CFM/CFC file was requested:
<cfoutput> cgi.request_method=#cgi.request_method#<br/> </cfoutput> <cfset req = getHTTPRequestData()> <cfoutput> getHTTPRequestData().method=#req.method# </cfoutput>
In the example above, the first way we check the request method is via the CGI scope. That's simple enough. But you can also use the ColdFusion function, getHTTPRequestData. This returns the method in the result structure.
Either of these methods should work fine for you.