developerforce / Force.com-JavaScript-REST-Toolkit

ForceTK - a minimal Force.com REST API for JavaScript apps
BSD 3-Clause "New" or "Revised" License
315 stars 175 forks source link

Allow to set header for apexrest function. #15

Closed chexxor closed 11 years ago

chexxor commented 12 years ago

I believe it's pretty common to set HTTP headers when using REST. I added a parameter to the apexrest function to pass in a map of header names to head values. What do you think?

Example:

forcetk.Client.apexrest('attach', function(msg){ alert('rest response'+msg); },//callback function(msg){ alert('err:'+msg.responseText); },//error 'POST',//method e.target.result,//payload {upload_filename:"filename", upload_pid:"parentObjectID"},//paramMap true);//retry

Signed-off-by: Alex Berg chexxor@gmail.com

chexxor commented 12 years ago

Alright, I moved the retry parameter to the far right. I also fixed the method called in the error callback. Good catch!

chexxor commented 12 years ago

Don't know if it's helpful, but here's a working example that uses the new method signature in this pull request.

https://github.com/chexxor/Multi-File-Uploader-Force.com/blob/master/src/staticresources/FileUploadRestJS.resource#L248

metadaddy commented 11 years ago

Wow - I can't believe this pull request is still open - apologies - merging now!