-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add http client component to runtime extension
- Loading branch information
1 parent
a7598a5
commit c4dbce3
Showing
13 changed files
with
322 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@smithy/fetch-http-handler": minor | ||
"@smithy/node-http-handler": minor | ||
"@smithy/protocol-http": minor | ||
"@smithy/util-test": minor | ||
--- | ||
|
||
Add http client component to runtime extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { HttpHandler } from "../httpHandler"; | ||
import { HttpHandlerExtensionConfiguration } from "./httpExtensionConfiguration"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getHttpHandlerConfiguration = (runtimeConfig: Partial<{ httpHandler: HttpHandler }>) => { | ||
const httpHandlerConfigs: Record<string, any> = {}; | ||
return { | ||
_httpHandler: runtimeConfig.httpHandler!, | ||
setHttpHandler(handler: HttpHandler): void { | ||
this._httpHandler = handler; | ||
}, | ||
httpHandler(): HttpHandler { | ||
return this._httpHandler; | ||
}, | ||
updateHttpClientConfig(key: string, value: any): void { | ||
httpHandlerConfigs[key] = value; | ||
}, | ||
httpHandlerConfigs(): Record<string, any> { | ||
return httpHandlerConfigs; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpHandlerRuntimeConfig = ( | ||
httpHandlerExtensionConfiguration: HttpHandlerExtensionConfiguration | ||
) => { | ||
const runtimeConfig: Partial<Record<string, HttpHandler>> = {}; | ||
runtimeConfig.requestHandler = httpHandlerExtensionConfiguration.httpHandler(); | ||
const record: Record<string, any> = httpHandlerExtensionConfiguration.httpHandlerConfigs(); | ||
for (const key in record) { | ||
runtimeConfig.requestHandler.updateHttpClientConfig(key, record[key]); | ||
} | ||
return runtimeConfig; | ||
}; |
42 changes: 42 additions & 0 deletions
42
packages/protocol-http/src/extensions/httpExtensionConfiguration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { HttpHandler } from "../httpHandler"; | ||
import { | ||
getHttpHandlerConfiguration, | ||
resolveHttpHandlerRuntimeConfig as _resolveHttpHandlerRuntimeConfig, | ||
} from "./http"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpHandlerExtensionConfiguration { | ||
setHttpHandler(handler: HttpHandler): void; | ||
httpHandler(): HttpHandler; | ||
updateHttpClientConfig(key: string, value: any): void; | ||
httpHandlerConfigs(): Record<string, any>; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type HttpHandlerExtensionConfigType = Parameters<typeof getHttpHandlerConfiguration>[0]; | ||
|
||
/** | ||
* @internal | ||
* | ||
* Helper function to resolve default extension configuration from runtime config | ||
*/ | ||
export const getHttpHandlerExtensionConfiguration = (runtimeConfig: HttpHandlerExtensionConfigType) => { | ||
return { | ||
...getHttpHandlerConfiguration(runtimeConfig), | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
* | ||
* Helper function to resolve runtime config from default extension configuration | ||
*/ | ||
export const resolveHttpHandlerRuntimeConfig = (config: HttpHandlerExtensionConfiguration) => { | ||
return { | ||
..._resolveHttpHandlerRuntimeConfig(config), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./httpExtensionConfiguration"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./extensions"; | ||
export * from "./Field"; | ||
export * from "./Fields"; | ||
export * from "./httpHandler"; | ||
|
Oops, something went wrong.