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

Disable Host Prefix in certain case #439

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.TopDownIndex;
import software.amazon.smithy.model.pattern.SmithyPattern;
import software.amazon.smithy.model.pattern.SmithyPattern.Segment;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;
Expand Down Expand Up @@ -64,6 +65,29 @@ public void processFinalizedModel(GoSettings settings, Model model) {
});
}

@Override
public void renderPostEndpointResolutionHook(GoSettings settings, GoWriter writer, Model model) {
boolean written = false;
for (OperationShape operation : endpointPrefixOperations) {
EndpointTrait endpointTrait = operation.expectTrait(EndpointTrait.class);

for (Segment segment : endpointTrait.getHostPrefix().getLabels()) {
if (segment.isLabel() && segment.getContent().equals("AccountId") && !written) {
writer.write(
"""
ctx = $T(ctx, true)
""",
SymbolUtils.createPointableSymbolBuilder("DisableEndpointHostPrefix", SmithyGoDependency.SMITHY_HTTP_TRANSPORT).build()
);
written = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought just in case there was a certain operation that satisfied:

                if (segment.isLabel() && segment.getContent().equals("AccountId") && !written) {

multiple times. i didnt want it to write out that context modification multiple times in the EP20 middleware

}
}

}

}


@Override
public List<RuntimeClientPlugin> getClientPlugins() {
return runtimeClientPlugins;
Expand Down
Loading