docs: update HttpInterceptor API docs (#26827)

PR Close #26827
This commit is contained in:
Vani 2018-10-29 09:35:33 -07:00 committed by Miško Hevery
parent 80a5934af6
commit aa8d0809d3
1 changed files with 14 additions and 17 deletions

View File

@ -14,32 +14,29 @@ import {HttpRequest} from './request';
import {HttpEvent} from './response'; import {HttpEvent} from './response';
/** /**
* Intercepts `HttpRequest` and handles them. * Intercepts `HttpRequest` or `HttpResponse` and handles them.
* *
* Most interceptors will transform the outgoing request before passing it to the * Most interceptors transforms the outgoing request before passing it to the
* next interceptor in the chain, by calling `next.handle(transformedReq)`. * next interceptor in the chain, by calling `next.handle(transformedReq)`.
* * An interceptor may choose to transform the
* In rare cases, interceptors may wish to completely handle a request themselves,
* and not delegate to the remainder of the chain. This behavior is allowed.
*
* @publicApi
*/
export interface HttpInterceptor {
/**
* Intercept an outgoing `HttpRequest` and optionally transform it or the
* response.
*
* Typically an interceptor will transform the outgoing request before returning
* `next.handle(transformedReq)`. An interceptor may choose to transform the
* response event stream as well, by applying additional Rx operators on the stream * response event stream as well, by applying additional Rx operators on the stream
* returned by `next.handle()`. * returned by `next.handle()`.
* *
* More rarely, an interceptor may choose to completely handle the request itself, * More rarely, an interceptor may choose to handle the request itself completely,
* and compose a new event stream instead of invoking `next.handle()`. This is * and compose a new event stream instead of invoking `next.handle()`. This is an
* acceptable behavior, but keep in mind further interceptors will be skipped entirely. * acceptable behavior, but keep in mind that further interceptors will be skipped entirely.
* *
* It is also rare but valid for an interceptor to return multiple responses on the * It is also rare but valid for an interceptor to return multiple responses on the
* event stream for a single request. * event stream for a single request.
*
* @publicApi
*
*/
export interface HttpInterceptor {
/**
* * **req**: The outgoing request to handle
* * **next**: The next interceptor in the chain
*
*/ */
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>; intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
} }