angular/angular.js — pull request #7267 by caitp (2014-04-27 02:31:38+00:00)
Title: chore($http): remove deprecated responseInterceptors functionality

Code cleanup! response interceptors have been deprecated for some time, and it
is confusing to have two APIs, one of which is slightly "hidden" and hard to
see, which perform the same task. The newer API is a bit cleaner and more
visible, so this is naturally preferred.

BREAKING CHANGE:

Previously, it was possible to register a response interceptor like so:

// register the interceptor as a service
$provide.factory('myHttpInterceptor', function($q, dependency1,
dependency2) {
return function(promise) {
return promise.then(function(response) {
// do something on success
return response;
}, function(response) {
// do something on error
if (canRecover(response)) {
return responseOrNewPromise
}
return $q.reject(response);
});
}
});

$httpProvider.responseInterceptors.push('myHttpInterceptor');

Now, one must use the newer API introduced in v1.1.4 (4ae46814), like so:

$provide.factory('myHttpInterceptor', function($q) {
return {
response: function(response) {
// do something on success
return response;
},
responseError: function(response) {
// do something on error
if (canRecover(response)) {
return responseOrNewPromise
}
return $q.reject(response);
}
};
});

$httpProvider.responseInterceptors.push('myHttpInterceptor');

Closes #7266