-
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
11f09b9
commit fbf7c58
Showing
14 changed files
with
333 additions
and
9 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,42 @@ | ||
import { HttpHandler } from "../httpHandler"; | ||
import { HttpHandlerExtensionConfiguration } from "./httpExtensionConfiguration"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getHttpHandlerConfiguration = <HandlerConfig extends object = Record<string, unknown>>( | ||
runtimeConfig: Partial<{ httpHandler: HttpHandler<HandlerConfig> }> | ||
) => { | ||
let httpHandler = runtimeConfig.httpHandler!; | ||
const httpHandlerConfigs: HandlerConfig = httpHandler.httpHandlerConfigs(); | ||
return { | ||
setHttpHandler(handler: HttpHandler<HandlerConfig>): void { | ||
httpHandler = handler; | ||
}, | ||
httpHandler(): HttpHandler<HandlerConfig> { | ||
return httpHandler; | ||
}, | ||
updateHttpClientConfig(key: keyof HandlerConfig, value: HandlerConfig[typeof key]): void { | ||
httpHandlerConfigs[key] = value; | ||
}, | ||
httpHandlerConfigs(): HandlerConfig { | ||
return httpHandlerConfigs; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpHandlerRuntimeConfig = <HandlerConfig extends object = Record<string, unknown>>( | ||
httpHandlerExtensionConfiguration: HttpHandlerExtensionConfiguration<HandlerConfig> | ||
) => { | ||
const requestHandler = httpHandlerExtensionConfiguration.httpHandler(); | ||
const handlerConfig = httpHandlerExtensionConfiguration.httpHandlerConfigs(); | ||
for (const key in handlerConfig) { | ||
requestHandler.updateHttpClientConfig(key, handlerConfig[key]); | ||
} | ||
return { | ||
requestHandler, | ||
}; | ||
}; |
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<HandlerConfig extends object = Record<string, unknown>> { | ||
setHttpHandler(handler: HttpHandler<HandlerConfig>): void; | ||
httpHandler(): HttpHandler<HandlerConfig>; | ||
updateHttpClientConfig(key: keyof HandlerConfig, value: HandlerConfig[typeof key]): void; | ||
httpHandlerConfigs(): HandlerConfig; | ||
} | ||
|
||
/** | ||
* @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.