|
36 | 36 | * @param {Object.<Object>=} actions Hash with declaration of custom action that should extend the |
37 | 37 | * default set of resource actions. The declaration should be created in the following format: |
38 | 38 | * |
39 | | - * {action1: {method:?, params:?, isArray:?}, |
40 | | - * action2: {method:?, params:?, isArray:?}, |
| 39 | + * {action1: {method:?, params:?, isArray:?, headers:?}, |
| 40 | + * action2: {method:?, params:?, isArray:?, headers:?}, |
41 | 41 | * ...} |
42 | 42 | * |
43 | 43 | * Where: |
|
49 | 49 | * - `params` – {object=} – Optional set of pre-bound parameters for this action. |
50 | 50 | * - isArray – {boolean=} – If true then the returned object for this action is an array, see |
51 | 51 | * `returns` section. |
| 52 | + * - `headers` – {object=} – Optional HTTP headers to send |
52 | 53 | * |
53 | 54 | * @returns {Object} A resource "class" object with methods for the default set of resource actions |
54 | 55 | * optionally extended with custom `actions`. The default set contains these actions: |
|
130 | 131 | * The object returned from this function execution is a resource "class" which has "static" method |
131 | 132 | * for each action in the definition. |
132 | 133 | * |
133 | | - * Calling these methods invoke `$http` on the `url` template with the given `method` and `params`. |
| 134 | + * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and `headers`. |
134 | 135 | * When the data is returned from the server then the object is an instance of the resource type and |
135 | 136 | * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD |
136 | 137 | * operations (create, read, update, delete) on server-side data. |
@@ -362,7 +363,8 @@ angular.module('ngResource', ['ng']). |
362 | 363 | $http({ |
363 | 364 | method: action.method, |
364 | 365 | url: route.url(extend({}, extractParams(data), action.params || {}, params)), |
365 | | - data: data |
| 366 | + data: data, |
| 367 | + headers: extend({}, action.headers || {}) |
366 | 368 | }).then(function(response) { |
367 | 369 | var data = response.data; |
368 | 370 |
|
|
0 commit comments