docs(API): 翻译完了 HttpInterceptor

This commit is contained in:
Zhicheng Wang 2018-09-04 13:33:50 +08:00
parent c3ec312159
commit 785aecb6dd
2 changed files with 19 additions and 2 deletions

View File

@ -55,7 +55,7 @@
[x] | core/OnChanges | 0.35
[x] | forms/FormControlName | 0.34
[x] | core/Output | 0.33
[ ] | common/http/HttpInterceptor | 0.30
[x] | common/http/HttpInterceptor | 0.30
[ ] | common/http/HttpRequest | 0.29
[ ] | router/CanActivate | 0.27
[ ] | router | 0.26

View File

@ -16,12 +16,17 @@ import {HttpEvent} from './response';
/**
* Intercepts `HttpRequest` and handles them.
*
* `HttpRequest`
*
* Most interceptors will transform the outgoing request before passing it to the
* next interceptor in the chain, by calling `next.handle(transformedReq)`.
*
* `next.handle(transformedReq)`
*
* 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.
*
*
*
*/
export interface HttpInterceptor {
@ -29,17 +34,27 @@ export interface HttpInterceptor {
* Intercept an outgoing `HttpRequest` and optionally transform it or the
* response.
*
* `HttpRequest`
*
* 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
* returned by `next.handle()`.
*
* `next.handle(transformedReq)`
* `next.handle()` Rx operator
*
* More rarely, an interceptor may choose to completely handle the request itself,
* and compose a new event stream instead of invoking `next.handle()`. This is
* acceptable behavior, but keep in mind further interceptors will be skipped entirely.
*
* `next.handle()`
*
*
* It is also rare but valid for an interceptor to return multiple responses on the
* event stream for a single request.
*
*
*/
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
}
@ -47,7 +62,7 @@ export interface HttpInterceptor {
/**
* `HttpHandler` which applies an `HttpInterceptor` to an `HttpRequest`.
*
*
* `HttpHandler` `HttpInterceptor` `HttpRequest`
*/
export class HttpInterceptorHandler implements HttpHandler {
constructor(private next: HttpHandler, private interceptor: HttpInterceptor) {}
@ -62,6 +77,8 @@ export class HttpInterceptorHandler implements HttpHandler {
* are registered.
*
*
* multi-provider `HttpInterceptor`
*
*/
export const HTTP_INTERCEPTORS = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS');