Skip to content

Commit

Permalink
Modify endpoint builtin codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianyi Wang committed Feb 6, 2024
1 parent 49f04d1 commit 1c68c88
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public GoWriter.Writable generate() {
loadResolvers();

return goTemplate("""
func $name:L(operation string, input interface{}, options Options, ctx $context:T) $params:P {
func $name:L(ctx $context:T, operation string, input interface{}, options Options) $params:P {
params := &$params:T{
Operation: operation,
}
Expand All @@ -64,7 +64,7 @@ public GoWriter.Writable generate() {
private GoWriter.Writable generateResolvers() {
return (writer) -> {
for (var resolver: resolvers) {
writer.write("$T(params, input, options, ctx)", resolver.resolver());
writer.write("$T(ctx, params, input, options)", resolver.resolver());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private GoWriter.Writable generateFields() {

private GoWriter.Writable generateBody() {
return goTemplate("""
params := $1L(m.operation, getOperationInput(ctx), m.options, ctx)
params := $1L(ctx, m.operation, getOperationInput(ctx), m.options)
options, err := m.options.AuthSchemeResolver.ResolveAuthSchemes(ctx, params)
if err != nil {
return out, metadata, $2T("resolve auth scheme: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private GoWriter.Writable generateAssertResolver() {

private GoWriter.Writable generateResolveEndpoint() {
return goTemplate("""
params := bindEndpointParams(getOperationInput(ctx), m.options, ctx)
params := bindEndpointParams(ctx, getOperationInput(ctx), m.options)
endpt, err := m.options.EndpointResolverV2.ResolveEndpoint(ctx, *params)
if err != nil {
return out, metadata, $1T("failed to resolve service endpoint, %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import software.amazon.smithy.go.codegen.GoStdlibTypes;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.integration.ProtocolGenerator;
import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter;
Expand Down Expand Up @@ -56,7 +57,7 @@ public GoWriter.Writable generate() {
bindEndpointParams(*EndpointParameters)
}
func bindEndpointParams(input interface{}, options Options, ctx context.Context) *EndpointParameters {
func bindEndpointParams(ctx $context:T, input interface{}, options Options) *EndpointParameters {
params := &EndpointParameters{}
$builtinBindings:W
Expand All @@ -71,6 +72,7 @@ func bindEndpointParams(input interface{}, options Options, ctx context.Context)
}
""",
MapUtils.of(
"context", GoStdlibTypes.Context.Context,
"builtinBindings", generateBuiltinBindings(),
"clientContextBindings", generateClientContextBindings()
));
Expand Down

0 comments on commit 1c68c88

Please sign in to comment.