-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Add hasBody to ngResource action configuration #12181
Changes from 1 commit
745d347
c6f2687
9e23624
be8aeeb
c8212ad
cf811f5
36ce9f0
9139302
77d9cfa
4e2a874
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,8 @@ function shallowClearAndCopy(src, dst) { | |
* - **`interceptor`** - `{Object=}` - The interceptor object has two optional methods - | ||
* `response` and `responseError`. Both `response` and `responseError` interceptors get called | ||
* with `http response` object. See {@link ng.$http $http interceptors}. | ||
* - **`hasBody`** - `{boolean}` - allows to specify if a request body is to be used (not | ||
* required for POST,PUT,PATCH and can't disable body inclusion on this methods). | ||
* | ||
* @param {Object} options Hash with custom settings that should extend the | ||
* default `$resourceProvider` behavior. The supported options are: | ||
|
@@ -640,7 +642,7 @@ angular.module('ngResource', ['ng']). | |
}; | ||
|
||
forEach(actions, function(action, name) { | ||
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method); | ||
var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method) || action.hasBody === true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would find something like the following more intuitive: var hasBody = action.hasBody === true || (action.hasBody !== false && /^(POST|PUT|PATCH)$/i.test(action.method)); Am I missing any reason why we shouldn't allow people to overwrite There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with both versions of the statement. Should I modify the patch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless you can think of a reason not to 😃 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to like twice to see the error but the correct statement would be: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually meant it the way I wrote it above. Your version is the same as: var hasBody = action.hasBody === true || /^(POST|PUT|PATCH)$/i.test(action.method); ...which is not what we want. |
||
var numericTimeout = action.timeout; | ||
var cancellable = isDefined(action.cancellable) ? | ||
action.cancellable : route.defaults.cancellable; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to change in order to reflect the new implementation.