angular/angular.js — pull request #3005 by wilsonjackson (2013-06-19 03:33:27+00:00)
Title: Allow promise returned by $http to be decorated

Exposes a `promiseDecorators` array on `$httpProvider` that can have functions pushed onto it. When `$http` is invoked, each decorator function will be called with the promise object that will be returned to the caller as an argument, allowing the decorator to add "flavor" methods, similar to `success()` and `error()`.

This is an implementation for the issue I created earlier this week, #2982. It's such a small change I figured I'd just throw it out there and see if there's any interest.

If you don't feel like clicking to the issue, here's the rationale: formerly you could decorate the promise object returned by `$http` using a response interceptor, but since the request interceptor refactoring that's no longer possible. This change allows users to add their own application domain–specific handler methods that can integrate with such non-standard cross-cutting concerns as validation and security handling. At present, the only ways to accomplish this are wrapping `$http`, putting it behind a proxy service, or replacing it completely.