Skip to content

Commit

Permalink
feat(compiler-cli): introduce HttpContext request context
Browse files Browse the repository at this point in the history
A long-requested feature for HttpClient is the ability to store and retrieve
custom metadata for requests, especially in interceptors. This commit
implements this functionality via a new context object for requests.

Each outgoing HttpRequest now has an associated "context", an instance of
the HttpContext class. An HttpContext can be provided when making a request,
or if not then an empty context is created for the new request. This context
shares its lifecycle with the entire request, even across operations that
change the identity of the HttpRequest instance such as RxJS retries.

The HttpContext functions as an expando. Users can create typed tokens as instances of HttpContextToken, and
read/write a value for the key from any HttpContext object.

This commit implements the HttpContext functionality. A followup commit will
add angular.io documentation.
  • Loading branch information
FDIM committed Feb 1, 2021
1 parent d754cc1 commit 2fcb6f9
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/common/http/public_api.ts
Expand Up @@ -8,6 +8,7 @@

export {HttpBackend, HttpHandler} from './src/backend';
export {HttpClient} from './src/client';
export {HttpContext, HttpContextToken} from './src/context';
export {HttpHeaders} from './src/headers';
export {HTTP_INTERCEPTORS, HttpInterceptor} from './src/interceptor';
export {JsonpClientBackend, JsonpInterceptor} from './src/jsonp';
Expand Down

0 comments on commit 2fcb6f9

Please sign in to comment.