Skip to content

Commit a4d6aa2

Browse files
Added default middleware chain construction note
1 parent 1f70fd2 commit a4d6aa2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/HTTPClientFactory.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export class HTTPClientFactory {
4040
* Creates HTTPClient with default middleware chain
4141
* @param {AuthenticationProvider} authProvider - The authentication provider instance
4242
* @returns A HTTPClient instance
43+
*
44+
* NOTE: These are the things that we need to remember while doing modifications in the below default pipeline.
45+
* * HTTPMessageHander should be the last one in the middleware pipeline, because this makes the actual network call of the request
46+
* * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag.
47+
* * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for
48+
* them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same.
4349
*/
4450
public static createWithAuthenticationProvider(authProvider: AuthenticationProvider): HTTPClient {
4551
const authenticationHandler = new AuthenticationHandler(authProvider);

0 commit comments

Comments
 (0)