Add cujojs/rest definition

This commit is contained in:
Wim Looman
2014-11-30 17:56:02 +13:00
committed by Wim Looman
parent 16fc1fb8b4
commit 96e9e1eef3
2 changed files with 132 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
/// <reference path="./rest.d.ts" />
import rest = require('rest');
import mime = require('rest/interceptor/mime');
import errorCode = require('rest/interceptor/errorCode');
import registry = require('rest/mime/registry');
rest('/').then(function(response) {
console.log('response: ', response);
});
var client = rest.wrap(mime);
client({ path: '/data.json' }).then(function(response) {
console.log('response: ', response);
});
client = rest.wrap(mime).wrap(errorCode, { code: 500 });
client({ path: '/data.json' }).then(
function(response) {
console.log('response: ', response);
},
function(response) {
console.error('response error: ', response);
}
);
registry.register('application/vnd.com.example', {
read: function(str: string) {
var obj: any;
// do string to object conversions
return obj;
},
write: function(obj: any) {
var str: string;
// do object to string conversions
return str;
}
});