Skip to content

Commit

Permalink
align static create and ctor signatures for http handlers (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Dec 5, 2023
1 parent 912961c commit e2e3f7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/serious-otters-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@smithy/fetch-http-handler": patch
"@smithy/node-http-handler": patch
---

align ctor and static creation signatures for http handlers
6 changes: 4 additions & 2 deletions packages/fetch-http-handler/src/fetch-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
public static create(instanceOrOptions?: HttpHandler<any> | FetchHttpHandlerConfig) {
public static create(
instanceOrOptions?: HttpHandler<any> | FetchHttpHandlerOptions | Provider<FetchHttpHandlerOptions | void>
) {
if (typeof (instanceOrOptions as any)?.handle === "function") {
// is already an instance of HttpHandler.
return instanceOrOptions as HttpHandler<any>;
Expand All @@ -41,7 +43,7 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
return new FetchHttpHandler(instanceOrOptions as FetchHttpHandlerConfig);
}

constructor(options?: FetchHttpHandlerOptions | Provider<FetchHttpHandlerOptions | undefined>) {
constructor(options?: FetchHttpHandlerOptions | Provider<FetchHttpHandlerOptions | void>) {
if (typeof options === "function") {
this.configProvider = options().then((opts) => opts || {});
} else {
Expand Down
4 changes: 3 additions & 1 deletion packages/node-http-handler/src/node-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class NodeHttpHandler implements HttpHandler<NodeHttpHandlerOptions> {
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
public static create(instanceOrOptions?: HttpHandler<any> | NodeHttpHandlerOptions) {
public static create(
instanceOrOptions?: HttpHandler<any> | NodeHttpHandlerOptions | Provider<NodeHttpHandlerOptions | void>
) {
if (typeof (instanceOrOptions as any)?.handle === "function") {
// is already an instance of HttpHandler.
return instanceOrOptions as HttpHandler<any>;
Expand Down
4 changes: 3 additions & 1 deletion packages/node-http-handler/src/node-http2-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export class NodeHttp2Handler implements HttpHandler<NodeHttp2HandlerOptions> {
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
public static create(instanceOrOptions?: HttpHandler<any> | NodeHttp2HandlerOptions) {
public static create(
instanceOrOptions?: HttpHandler<any> | NodeHttp2HandlerOptions | Provider<NodeHttp2HandlerOptions | void>
) {
if (typeof (instanceOrOptions as any)?.handle === "function") {
// is already an instance of HttpHandler.
return instanceOrOptions as HttpHandler<any>;
Expand Down

0 comments on commit e2e3f7d

Please sign in to comment.