Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Talking to REST services made simple

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 dist
Octocat-spinner-32 examples
Octocat-spinner-32 source
Octocat-spinner-32 spec
Octocat-spinner-32 vendor
Octocat-spinner-32 Rakefile
Octocat-spinner-32 Readme.md
Readme.md

Request pack

Request pack consists of two classes which make consuming REST services really easy.

It's built for use with web runtimes such as Titanium Desktop or Google Chrome Applications.

Why not just use jQuery/Prototype/AwesomeFramework?

Because it's simple and just works. It also doesn't depend on any other library (except jsOAuth).

API

RequestPack consists of two classes, each using same interface, but differing in the way authentication works:

  • Request - is a wrapper around XMLHttpRequest and provides simple interface which is suitable for any sane API
  • OAuthRequest - has the same API but uses jsOAuth as the core for making requests:

Request

Request is easy to use and provides neat abstraction from regular XMLHttpRequest stuff:

req = new Req 'http://server.com/api', { accept : 'application/json'} , {username : 'lol', password : 'wat'}

req.get('/chunkybacon',
  onSuccess : (request) -> console.log(request.responseText)
  onFailure : (request) -> alert 'no bacon for you, lad'
)

...or in Javascript:

var req = new Req('http://server.com/api', { accept : 'application/json'} , {username : 'lol', password : 'wat'})

req.get('/chunkybacon', {
  onSuccess : function(request) {
    console.log(request.responseText);
  },
  onFailure : function(request) {
    alert( 'no bacon for you, lad');
  }
});

See Campfire class in examples directory for more details.

TODO

moar docs

Licence

MIT

Something went wrong with that request. Please try again.