From 722f0b1abbb05400f889330796e733ae9dab10e3 Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Fri, 27 Aug 2021 12:49:11 -0700 Subject: [PATCH] Allow setting prefix path for rpc protocols (#406) --- .../codegen/integration/HttpRpcProtocolGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java index 35576f66d94..52fb8e89309 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java @@ -114,13 +114,13 @@ public void generateSharedComponents(GenerationContext context) { + "): Promise<$T> => {", "};", requestType, () -> { // Get the hostname, port, and scheme from client's resolved endpoint. Then construct the request from // them. The client's resolved endpoint can be default one or supplied by users. - writer.write("const {hostname, protocol = \"https\", port} = await context.endpoint();"); + writer.write("const {hostname, protocol = \"https\", port, path: basePath} = await context.endpoint();"); writer.openBlock("const contents: any = {", "};", () -> { writer.write("protocol,"); writer.write("hostname,"); writer.write("port,"); writer.write("method: \"POST\","); - writer.write("path,"); + writer.write("path: basePath.endsWith(\"/\") ? basePath.slice(0, -1) + path : basePath + path,"); writer.write("headers,"); }); writer.openBlock("if (resolvedHostname !== undefined) {", "}", () -> {