diff options
| author | Igor Minar | 2011-11-30 03:58:34 -0500 |
|---|---|---|
| committer | Igor Minar | 2011-11-30 14:49:35 -0500 |
| commit | 188bdf7768c9594a01a18abae3fa9a3114802508 (patch) | |
| tree | 01116c84c9985f284a7530fa6a15fd8e27453d1b /src/service/http.js | |
| parent | dbd880cc0a9521bd5b9c96ca3f052450c3def336 (diff) | |
| download | angular.js-188bdf7768c9594a01a18abae3fa9a3114802508.tar.bz2 | |
feat($http): add response interceptors
Diffstat (limited to 'src/service/http.js')
| -rw-r--r-- | src/service/http.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/service/http.js b/src/service/http.js index 5666f486..bdf55937 100644 --- a/src/service/http.js +++ b/src/service/http.js @@ -81,6 +81,8 @@ function $HttpProvider() { } }; + var responseInterceptors = this.responseInterceptors = []; + this.$get = ['$httpBackend', '$browser', '$exceptionHandler', '$cacheFactory', '$rootScope', '$q', function($httpBackend, $browser, $exceptionHandler, $cacheFactory, $rootScope, $q) { @@ -129,6 +131,10 @@ function $HttpProvider() { deferredResp = $q.defer(), promise = deferredResp.promise; + forEach(responseInterceptors, function(interceptor) { + promise = interceptor(promise); + }); + promise.success = function(fn) { promise.then(function(response) { fn(response.data, response.status, response.headers, config); |
