diff options
| author | Max Martinsson | 2012-05-17 17:11:25 +0200 | 
|---|---|---|
| committer | Misko Hevery | 2012-09-06 15:49:48 -0700 | 
| commit | b936e52874fe0173c6d4ba0a84f45deac67518ac (patch) | |
| tree | 21b5dee407c2137a538b51cfbc27c7ffc3e9c82d /src/ngResource | |
| parent | 0d52ff0f10157aa7d93a77abc78f6a6a6c3f6e45 (diff) | |
| download | angular.js-b936e52874fe0173c6d4ba0a84f45deac67518ac.tar.bz2 | |
feat($resource): support custom headers per action
Closes #736
Diffstat (limited to 'src/ngResource')
| -rw-r--r-- | src/ngResource/resource.js | 10 | 
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index 5bf3e07a..166fc9b8 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -36,8 +36,8 @@   * @param {Object.<Object>=} actions Hash with declaration of custom action that should extend the   *   default set of resource actions. The declaration should be created in the following format:   * - *       {action1: {method:?, params:?, isArray:?}, - *        action2: {method:?, params:?, isArray:?}, + *       {action1: {method:?, params:?, isArray:?, headers:?}, + *        action2: {method:?, params:?, isArray:?, headers:?},   *        ...}   *   *   Where: @@ -49,6 +49,7 @@   *   - `params` – {object=} – Optional set of pre-bound parameters for this action.   *   - isArray – {boolean=} – If true then the returned object for this action is an array, see   *     `returns` section. + *   - `headers` – {object=} – Optional HTTP headers to send   *   * @returns {Object} A resource "class" object with methods for the default set of resource actions   *   optionally extended with custom `actions`. The default set contains these actions: @@ -130,7 +131,7 @@   * The object returned from this function execution is a resource "class" which has "static" method   * for each action in the definition.   * - * Calling these methods invoke `$http` on the `url` template with the given `method` and `params`. + * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and `headers`.   * When the data is returned from the server then the object is an instance of the resource type and   * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD   * operations (create, read, update, delete) on server-side data. @@ -362,7 +363,8 @@ angular.module('ngResource', ['ng']).            $http({              method: action.method,              url: route.url(extend({}, extractParams(data), action.params || {}, params)), -            data: data +            data: data, +            headers: extend({}, action.headers || {})            }).then(function(response) {                var data = response.data;  | 
