5 lines
9.8 KiB
JSON
5 lines
9.8 KiB
JSON
{
|
|
"id": "api/common/http/HttpInterceptor",
|
|
"title": "HttpInterceptor",
|
|
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/common\", \"name\": \"@angular/common\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/common/http\", \"name\": \"@angular/common/http\" } },\n { \"@type\": \"ListItem\", \"position\": 4, \"item\": { \"@id\": \"https://angular.io/api/common/http/HttpInterceptor\", \"name\": \"HttpInterceptor\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/common\">@angular/common</a> > <a href=\"api/common/http\">@angular/common/http</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/http/src/interceptor.ts?message=docs(common)%3A%20describe%20your%20change...#L15-L54\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/http/src/interceptor.ts#L15-L54\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"httpinterceptor\">HttpInterceptor<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#httpinterceptor\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label interface\">interface</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Intercepts and handles an <code><a href=\"api/common/http/HttpRequest\" class=\"code-anchor\">HttpRequest</a></code> or <code><a href=\"api/common/http/HttpResponse\" class=\"code-anchor\">HttpResponse</a></code>.</p>\n\n <p><a href=\"api/common/http/HttpInterceptor#description\">See more...</a></p>\n </section>\n \n \n <section class=\"interface-overview\">\n<code-example language=\"ts\" hidecopy=\"true\">\ninterface <a href=\"api/common/http/HttpInterceptor\" class=\"code-anchor\">HttpInterceptor</a> {\n <a class=\"code-anchor\" href=\"api/common/http/HttpInterceptor#intercept\"><span class=\"member-name\">intercept</span>(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>></a>\n}\n</code-example>\n\n \n \n\n\n \n \n\n</section>\n\n \n<section class=\"see-also\">\n <h2 id=\"see-also\">See also<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#see-also\"><i class=\"material-icons\">link</i></a></h2>\n <ul>\n \n <li><p><a href=\"guide/http#intercepting-requests-and-responses\">HTTP Guide</a></p>\n</li>\n </ul>\n</section>\n\n\n \n \n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>Most interceptors transform the outgoing request before passing it to the\nnext interceptor in the chain, by calling <code>next.handle(transformedReq)</code>.\nAn interceptor may transform the\nresponse event stream as well, by applying additional RxJS operators on the stream\nreturned by <code>next.handle()</code>.</p>\n<p>More rarely, an interceptor may handle the request entirely,\nand compose a new event stream instead of invoking <code>next.handle()</code>. This is an\nacceptable behavior, but keep in mind that further interceptors will be skipped entirely.</p>\n<p>It is also rare but valid for an interceptor to return multiple responses on the\nevent stream for a single request.</p>\n\n <p>Further information available in the <a href=\"api/common/http/HttpInterceptor#usage-notes\">Usage Notes</a>...</p>\n</section>\n\n \n\n \n\n<section class=\"instance-methods\">\n <h2 id=\"methods\">Methods<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#methods\"><i class=\"material-icons\">link</i></a></h2>\n \n <a id=\"intercept\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"intercept\">\n intercept()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#intercept\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/http/src/interceptor.ts?message=docs(common)%3A%20describe%20your%20change...#L46-L53\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/http/src/interceptor.ts#L46-L53\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n <tr>\n <td class=\"short-description\">\n <p>Identifies and handles a given HTTP request.</p>\n\n </td>\n </tr>\n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">intercept</span>(req: <a href=\"api/common/http/HttpRequest\" class=\"code-anchor\">HttpRequest</a><any>, next: <a href=\"api/common/http/HttpHandler\" class=\"code-anchor\">HttpHandler</a>): Observable<<a href=\"api/common/http/HttpEvent\" class=\"code-anchor\">HttpEvent</a><any>></code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>req</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/common/http/HttpRequest\" class=\"code-anchor\">HttpRequest</a><any></any></code></td>\n <td class=\"param-description\">\n <p>The outgoing request object to handle.</p>\n\n </td>\n </tr>\n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>next</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/common/http/HttpHandler\" class=\"code-anchor\">HttpHandler</a></code></td>\n <td class=\"param-description\">\n <p>The next interceptor in the chain, or the backend\nif no interceptors remain in the chain.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns\">Returns</h6>\n <p><code>Observable<<a href=\"api/common/http/HttpEvent\" class=\"code-anchor\">HttpEvent</a><any>></code>: An observable of the event stream.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n</section>\n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/http/HttpInterceptor#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>To use the same instance of <code>HttpInterceptors</code> for the entire app, import the <code><a href=\"api/common/http/HttpClientModule\" class=\"code-anchor\">HttpClientModule</a></code>\nonly in your <code>AppModule</code>, and add the interceptors to the root application injector .\nIf you import <code><a href=\"api/common/http/HttpClientModule\" class=\"code-anchor\">HttpClientModule</a></code> multiple times across different modules (for example, in lazy\nloading modules), each import creates a new copy of the <code><a href=\"api/common/http/HttpClientModule\" class=\"code-anchor\">HttpClientModule</a></code>, which overwrites the\ninterceptors provided in the root module.</p>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/common/http\n - api/common/http/HTTP_INTERCEPTORS\n - api/common/http/HttpContext\n - api/common/http/HttpHandler\n - api/common/http/JsonpInterceptor\n - guide/http\n-->\n<!-- links from this doc:\n - /api\n - api/common\n - api/common/http\n - api/common/http/HttpClientModule\n - api/common/http/HttpEvent\n - api/common/http/HttpHandler\n - api/common/http/HttpInterceptor#description\n - api/common/http/HttpInterceptor#httpinterceptor\n - api/common/http/HttpInterceptor#intercept\n - api/common/http/HttpInterceptor#methods\n - api/common/http/HttpInterceptor#see-also\n - api/common/http/HttpInterceptor#usage-notes\n - api/common/http/HttpRequest\n - api/common/http/HttpResponse\n - guide/http#intercepting-requests-and-responses\n - https://github.com/angular/angular/edit/master/packages/common/http/src/interceptor.ts?message=docs(common)%3A%20describe%20your%20change...#L15-L54\n - https://github.com/angular/angular/edit/master/packages/common/http/src/interceptor.ts?message=docs(common)%3A%20describe%20your%20change...#L46-L53\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/http/src/interceptor.ts#L15-L54\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/http/src/interceptor.ts#L46-L53\n-->"
|
|
} |