Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($http): add the PATCH shortcut back #5894

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,21 @@ function $HttpProvider() {
* @param {Object=} config Optional configuration object
* @returns {HttpPromise} Future object
*/
createShortMethodsWithData('post', 'put');

/**
* @ngdoc method
* @name ng.$http#patch
* @methodOf ng.$http
*
* @description
* Shortcut method to perform `PATCH` request.
*
* @param {string} url Relative or absolute URL specifying the destination of the request
* @param {*} data Request content
* @param {Object=} config Optional configuration object
* @returns {HttpPromise} Future object
*/
createShortMethodsWithData('post', 'put', 'patch');

/**
* @ngdoc property
Expand Down
9 changes: 9 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,15 @@ describe('$http', function() {
$http.put('/url', 'some-data', {headers: {'Custom': 'Header'}});
});

it('should have patch()', function(){
$httpBackend.expect('PATCH', '/url', 'some-data').respond('');
$http.patch('/url', 'some-data');
});

it('patch() should allow config param', function() {
$httpBackend.expect('PATCH', '/url', 'some-data', checkHeader('Custom', 'Header')).respond('');
$http.patch('/url', 'some-data', {headers: {'Custom': 'Header'}});
});

it('should have jsonp()', function() {
$httpBackend.expect('JSONP', '/url').respond('');
Expand Down