diff --git a/LICENSE b/LICENSE index 3cecbb8..221d4b3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -rest-client.js is licensed under the terms of MIT License. +hateoas-client.js is licensed under the terms of MIT License. Copyright (c) 2011-2014 by DracoBlue (JanS@DracoBlue.de) diff --git a/README.md b/README.md index 48c6979..1f9c82a 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -rest-client.js README +hateoas-client.js README ======================= This client is still a rough draft of how one could make this client happen. The api is subject to change and comments and help is appriciated! -* Latest Release: [![GitHub version](https://badge.fury.io/gh/DracoBlue%2Frest-client-js.png)](https://github.com/DracoBlue/rest-client-js/releases) +* Latest Release: [![GitHub version](https://badge.fury.io/gh/DracoBlue%2Fhateoas-client-js.png)](https://github.com/DracoBlue/hateoas-client-js/releases) * Official Site: -rest-client.js is copyright 2011-2014 by DracoBlue +hateoas-client.js is copyright 2011-2014 by DracoBlue -What is rest-client.js? +What is hateoas-client.js? ----------------------- -rest-client.js is a library to communicate with RESTful services. It uses +hateoas-client.js is a library to communicate with RESTful services. It uses jQuery as ajax library. It's aim is to provide a very simple API to follow the `links` defined in a request response, thus achieving level 3 in `Richardson Maturity Model`. @@ -26,7 +26,7 @@ How does it work? ### Example with JSON -If you include `rest-client.js` after your `jQuery.js`, you'll have the ability +If you include `hateoas-client.js` after your `jQuery.js`, you'll have the ability to make such requests: var a = new HttpAgent('/api'); @@ -71,11 +71,11 @@ That example also shows, how one can use the `proxy_script`-option to use a Usage with require.js --------------------- -If you want to retrieve the HttpAgent in your require.js script use (ensure that `rest-client-js` maps on `rest-client.js` +If you want to retrieve the HttpAgent in your require.js script use (ensure that `hateoas-client-js` maps on `hateoas-client.js` in your requirejs config file): ``` javascript -require('rest-client-js', function(rest_client) { +require('hateoas-client', function(rest_client) { var a = new rest_client.HttpAgent('/api'); }); ``` @@ -93,6 +93,7 @@ Changelog --------- * dev + - renamed to hateoas-client.js - handle relative paths in links (by asking HttpAgent for the base url) - Added FIXME method for getLinks on HTML/XML objects - added nodejs support with domino, jquery and xmlhttprequest for nodejs @@ -113,4 +114,4 @@ Changelog License -------- -rest-client.js is licensed under the terms of MIT. See LICENSE for more information. +hateoas-client.js is licensed under the terms of MIT. See LICENSE for more information. diff --git a/bower.json b/bower.json index 81a7d49..8ac9074 100644 --- a/bower.json +++ b/bower.json @@ -1,11 +1,11 @@ { - "name": "rest-client-js", - "main": "rest-client.js", - "homepage": "https://github.com/DracoBlue/rest-client-js", + "name": "hateoas-client", + "main": "hateoas-client.js", + "homepage": "https://github.com/DracoBlue/hateoas-client-js", "authors": [ "DracoBlue " ], - "description": "rest-client.js is a library to communicate with RESTful services. It uses jQuery as ajax library. It's aim is to provide a very simple API to follow the links defined in a request response, thus achieving level 3 in Richardson Maturity Model.", + "description": "hateoas-client.js is a library to communicate with RESTful services. It uses jQuery as ajax library. It's aim is to provide a very simple API to follow the links defined in a request response, thus achieving level 3 in Richardson Maturity Model.", "moduleType": [ "amd", "globals" diff --git a/example/buy_coffee.html b/example/buy_coffee.html index 9fe7236..3d6ff31 100644 --- a/example/buy_coffee.html +++ b/example/buy_coffee.html @@ -2,7 +2,7 @@ - + Please see your browsers console.log for output! diff --git a/example/hal_coffee.html b/example/hal_coffee.html index 57ef99c..dde5561 100644 --- a/example/hal_coffee.html +++ b/example/hal_coffee.html @@ -2,7 +2,7 @@ - + Please see your browsers console.log for output! diff --git a/example/leave_the_maze.html b/example/leave_the_maze.html index a9d3674..6e909e8 100644 --- a/example/leave_the_maze.html +++ b/example/leave_the_maze.html @@ -2,7 +2,7 @@ - + Please see your browsers console.log for output! diff --git a/example/show_atom_archive.html b/example/show_atom_archive.html index 67718cb..229adae 100644 --- a/example/show_atom_archive.html +++ b/example/show_atom_archive.html @@ -2,7 +2,7 @@ - + Please see your browsers console.log for output! diff --git a/rest-client.js b/hateoas-client.js similarity index 98% rename from rest-client.js rename to hateoas-client.js index f79a854..55e1231 100644 --- a/rest-client.js +++ b/hateoas-client.js @@ -58,7 +58,7 @@ HttpAgent.prototype.rawCall = function(cb, verb, params, headers) { if (this.options.proxy_script) { url = this.options.proxy_script + encodeURIComponent(url); } - + jQuery.ajax({ beforeSend: function(xhrObj){ for (var header in that.default_headers) @@ -183,6 +183,14 @@ HttpAgent.prototype.rawBreadthFirstSearch = function(cb, filter_object) { cb(links[filter_object][0], response); return ; } + + if (typeof filter_object === "function") { + if (filter_object(response)) + { + cb(tmp_entry_point.clone(), response); + return ; + } + } if (typeof filter_object !== "string") { try { @@ -689,7 +697,7 @@ HttpAgent.registerResponseContentTypes(['text/html', 'application/xml'], XmlHttp if (typeof define !== "undefined") { - define('rest-client-js', [], function () { + define('hateoas-client-js', [], function () { return { "HttpAgent": HttpAgent }; diff --git a/package.json b/package.json index cc6a66f..0e96894 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "rest-client.js", + "name": "hateoas-client", "description": "A library to communicate with RESTful services. It's aim is to provide a very simple API to follow the links defined in a request response, thus achieving level 3 in Richardson Maturity Model.", - "main": "rest-client.js", + "main": "hateoas-client.js", "directories": { "example": "example" }, @@ -10,7 +10,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/DracoBlue/rest-client-js.git" + "url": "https://github.com/DracoBlue/hateoas-client-js.git" }, "keywords": [ "rest", @@ -24,9 +24,9 @@ "author": "DracoBlue ", "license": "MIT", "bugs": { - "url": "https://github.com/DracoBlue/rest-client-js/issues" + "url": "https://github.com/DracoBlue/hateoas-client-js/issues" }, - "homepage": "https://github.com/DracoBlue/rest-client-js", + "homepage": "https://github.com/DracoBlue/hateoas-client-js", "dependencies": { "domino": "^1.0.18", "jquery": "^2.1.3",