When I try and install relax from forgebox from with in my app
or go to
http://www.coldbox.org/forgebox/view/coldbox-relax
I was able to download from
https://github.com/coldbox/coldbox-relax
When I try and install relax from forgebox from with in my app
or go to
http://www.coldbox.org/forgebox/view/coldbox-relax
I was able to download from
https://github.com/coldbox/coldbox-relax
it is working now
Thank you internet pixies
Hi Luis,
I have been messing around with a RESTful plugin for CFWheels and am now taking a look at ColdBox Relax.
I called my CFWheels RESTful services from RelaxURL
and noticed that the format (XML, JSON, …) is just been appended to the URL.
As I understand it, it is better to pass it as a HEADER param, namely ‘Accept’
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
And when it come to passing content in, you tell the service the format it is with ‘Content-Type’
This is how I am calling my RESTful service
http url=“http://mydomain.com.au/api/instruments/#PARAMS.Key#/” method=“GET” result=“loc.instrument” throwOnError=“true” {
httpparam type=“HEADER” name=“Accept” value="#loc.Accept#";
httpparam type=“HEADER” name=“Content-Type” value=“application/json; charset=UTF-8”;
}
Hi A J, I think you might be misunderstanding the convention here.
The idea is that you can create a handler, that is say
http://domain/documents/YTDReport
Now the idea here is that by just changing the URL slightlty say to
http://domain/documents/YTDReport.json is like saying call that handler, and tell them that I am expecting a Json representation of the report.
Used in combination of renderData() this becomes fairly good very quick.
Regards,
Andrew Scott
well, this is what I am researching and am planning on submitting as a topic for cf.Objective(ANZ)
because I think people are confusing RESTful style URLs for their application and a RESTful Service.
So, I think it is totally valid for an application to append .json to a URL to get data returned in that format.
The application however, when calling the RESTful Service, should invoke it with proper headers.
And also, I have seen that is is common practice to fake up a DELETE method with a hidden form field call ‘_method’.
Again, this is acceptable, in my opinion, for the application when displaying a form, but when that application calls the RESTful service, it should use METHOD=DELETE.
CFML can do this using CFHTTP
If you want to do it straight from the browser, you can use JS library like jQuery and use it’s ajax function.
I am new to RESTful services and am very happy to discuss what other people are doing.
I couldn’t agree with you more there, and people will do just that. But it is also up to the calling application to deal with the send/receive (for results) requests, and I don’t think that a framework that also provides an easier alternative can really be held to blame here.
Regards,
Andrew Scott
OK, so maybe I am getting mixed with RelaxURL - it is an application
So I add an API header ‘Accept’ = ‘JSON’
but when it gets to my service (CFWheels with plugin running on Railo) it appears as as ‘accept’ (notice the lower case a for accept)
HttpRequestData
Struct
content
string
headers
Struct
accept
string
JSON
host
string
user-agent
string
ColdBox Relax
method
string
GET
protocol
string
HTTP/1.1
Should casing be preserved?
But not knowing railo could it be that they do the opposite to ACF, and put all keys as lower case when dumping?
Regards,
Andrew Scott
I am using
but I will investigate from the Railo side and report back
Why would you care the case if you are using cf anyways? Also as far as content types go here is my comment
Rest is just an architectural style not a specific guideline so it is open to doing things differently and not in one single manner. I prefer the content type to be appended to the resource as it is very easy to remember and test and visualize. If you want to use content types via header that is also acceptable. Actrually in coldbox 3.1 we will be adding that feature which I did not complete entirely which is detect the content type from the headers and automatically setup the format variable much how we do the extension detection.
So again, it is a matter of choice of how you want to define your restful service. The only thing that I should say is mandatory is that you document that
Luis Majano
President
Ortus Solutions, Corp
www.ortussolutions.com
www.luismajano.com
OK then, whilst I think with just makes services inconsistent, I can see the attraction of the extension.
I will tweak my service to look for an extension if the Header does not exist.
As for structs, I have take to using the struct[‘Key’] format
as it relives a lot of headaches when dealing with environments that are case sensitive such as JavaScript and Flash Remoting.
Whilst CFML is not case sensitive, systems that call the service (and vise versa) maybe.
I think is is a safer approach to enforce casing everywhere.
Hmmm - looks like the weekend did me some good - it all seems to be working nicely now.
The only think I can think of was in relaxURL I was using ‘API Parameters’ instead of ‘API Headers’
And I have added a check for url extension if header Accept does not exist for my CFWheels plugin