docs($http): clear up Interceptor docs and code

The documentation and code example of $http interceptors is unclear about whether config can be null
or not, and whether the result should always be a promise or not. This pr clears up the documentation
a bit and removes the literal 'or a promise' interpretation of the docs in the code example.

Closes #7431
Closes #7460
This commit is contained in:
Freek Wielstra
2014-05-14 13:25:08 +02:00
committed by Igor Minar
parent f2f5a1dd39
commit 1fe0d9990e

View File

@@ -328,14 +328,14 @@ function $HttpProvider() {
*
* There are two kinds of interceptors (and two kinds of rejection interceptors):
*
* * `request`: interceptors get called with http `config` object. The function is free to
* modify the `config` or create a new one. The function needs to return the `config`
* directly or as a promise.
* * `request`: interceptors get called with a http `config` object. The function is free to
* modify the `config` object or create a new one. The function needs to return the `config`
* object directly, or a promise containing the `config` or a new `config` object.
* * `requestError`: interceptor gets called when a previous interceptor threw an error or
* resolved with a rejection.
* * `response`: interceptors get called with http `response` object. The function is free to
* modify the `response` or create a new one. The function needs to return the `response`
* directly or as a promise.
* modify the `response` object or create a new one. The function needs to return the `response`
* object directly, or as a promise containing the `response` or a new `response` object.
* * `responseError`: interceptor gets called when a previous interceptor threw an error or
* resolved with a rejection.
*
@@ -347,7 +347,7 @@ function $HttpProvider() {
* // optional method
* 'request': function(config) {
* // do something on success
* return config || $q.when(config);
* return config;
* },
*
* // optional method
@@ -364,7 +364,7 @@ function $HttpProvider() {
* // optional method
* 'response': function(response) {
* // do something on success
* return response || $q.when(response);
* return response;
* },
*
* // optional method