-
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
697310d
commit d8940f5
Showing
14 changed files
with
305 additions
and
8 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
56 changes: 56 additions & 0 deletions
56
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,56 @@ | ||
import { HttpHandler } from "../httpHandler"; | ||
|
||
/** | ||
* @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<HandlerConfig extends object = Record<string, unknown>> = Partial<{ | ||
httpHandler: HttpHandler<HandlerConfig>; | ||
}>; | ||
|
||
/** | ||
* @internal | ||
* | ||
* Helper function to resolve default extension configuration from runtime config | ||
*/ | ||
export const getHttpHandlerExtensionConfiguration = <HandlerConfig extends object = Record<string, unknown>>( | ||
runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> | ||
) => { | ||
let httpHandler = runtimeConfig.httpHandler!; | ||
return { | ||
setHttpHandler(handler: HttpHandler<HandlerConfig>): void { | ||
httpHandler = handler; | ||
}, | ||
httpHandler(): HttpHandler<HandlerConfig> { | ||
return httpHandler; | ||
}, | ||
updateHttpClientConfig(key: keyof HandlerConfig, value: HandlerConfig[typeof key]): void { | ||
httpHandler.updateHttpClientConfig(key, value); | ||
}, | ||
httpHandlerConfigs(): HandlerConfig { | ||
return httpHandler.httpHandlerConfigs(); | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
* | ||
* Helper function to resolve runtime config from default extension configuration | ||
*/ | ||
export const resolveHttpHandlerRuntimeConfig = <HandlerConfig extends object = Record<string, unknown>>( | ||
httpHandlerExtensionConfiguration: HttpHandlerExtensionConfiguration<HandlerConfig> | ||
) => { | ||
return { | ||
requestHandler: httpHandlerExtensionConfiguration.httpHandler(), | ||
} as HttpHandlerExtensionConfigType<HandlerConfig>; | ||
}; |
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"; | ||
|
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
Oops, something went wrong.