Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable ctor arg passthrough for requestHandler (Java codegen) #1168

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/orange-beans-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class RuntimeConfigGenerator {
writer.addDependency(TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER);
writer.addImport("NodeHttpHandler", "RequestHandler",
TypeScriptDependency.AWS_SDK_NODE_HTTP_HANDLER);
writer.write("new RequestHandler(defaultConfigProvider)");
writer.write("RequestHandler.create(config?.requestHandler ?? defaultConfigProvider)");
},
"sha256", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_HASH_NODE);
Expand All @@ -81,7 +81,7 @@ final class RuntimeConfigGenerator {
writer.addDependency(TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER);
writer.addImport("FetchHttpHandler", "RequestHandler",
TypeScriptDependency.AWS_SDK_FETCH_HTTP_HANDLER);
writer.write("new RequestHandler(defaultConfigProvider)");
writer.write("RequestHandler.create(config?.requestHandler ?? defaultConfigProvider)");
},
"sha256", writer -> {
writer.addDependency(TypeScriptDependency.AWS_CRYPTO_SHA256_BROWSER);
Expand Down Expand Up @@ -197,11 +197,20 @@ void generate(LanguageTarget target) {
}
int indentation = target.equals(LanguageTarget.SHARED) ? 1 : 2;
configs.forEach((key, value) -> {
writer.indent(indentation).disableNewlines().openBlock("$1L: config?.$1L ?? ", ",\n", key,
() -> {
value.accept(writer);
});
writer.dedent(indentation);
String defaultPrefix = "config?.$1L ?? ";
if (key.equals("requestHandler")) {
defaultPrefix = "";
}
writer
.indent(indentation)
.disableNewlines()
.openBlock(
"$1L: " + defaultPrefix, ",\n", key,
() -> {
value.accept(writer);
}
)
.dedent(indentation);
syall marked this conversation as resolved.
Show resolved Hide resolved
});
});
writer.dedent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,13 @@ private void generateClientDefaults() {

writer.writeDocs("@public")
.openBlock("export interface ClientDefaults\n"
+ " extends Partial<__SmithyResolvedConfiguration<$T>> {", "}",
+ " extends Partial<__SmithyConfiguration<$T>> {", "}",
applicationProtocol.getOptionsType(), () -> {
writer.addImport("HttpHandler", "__HttpHandler", TypeScriptDependency.PROTOCOL_HTTP);
writer.writeDocs("The HTTP handler to use. Fetch in browser and Https in Nodejs.");
writer.write("requestHandler?: __HttpHandler;\n");
writer.addImport("HttpHandlerUserInput", "__HttpHandlerUserInput", TypeScriptDependency.PROTOCOL_HTTP);
writer.writeDocs(
"The HTTP handler to use or its constructor options. Fetch in browser and Https in Nodejs."
);
writer.write("requestHandler?: __HttpHandlerUserInput;\n");

writer.addImport("HashConstructor", "__HashConstructor", TypeScriptDependency.SMITHY_TYPES);
writer.addImport("ChecksumConstructor", "__ChecksumConstructor", TypeScriptDependency.SMITHY_TYPES);
Expand Down
Loading