From a4dea73b53b95f5637ba3efcc1f6a2e2b0b3cf78 Mon Sep 17 00:00:00 2001 From: Kamran Biglari <102748921+KamranBiglari@users.noreply.github.com> Date: Fri, 29 Sep 2023 13:21:35 +0100 Subject: [PATCH 1/2] add hostPrefix --- src/resty/aws/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/resty/aws/init.lua b/src/resty/aws/init.lua index 8422a52..212a093 100644 --- a/src/resty/aws/init.lua +++ b/src/resty/aws/init.lua @@ -9,7 +9,6 @@ local split = require("pl.utils").split local tablex = require("pl.tablex") - -- case-insensitive lookup help. -- always throws an error! local lookup_helper = function(self, key) -- signature to match __index meta-method @@ -298,6 +297,14 @@ local function generate_service_methods(service) -- decapitalize first character of method names to mimic JS sdk local method_name = operation.name:sub(1,1):lower() .. operation.name:sub(2,-1) + -- add hostPrefix for the methods that needs hostPrefix + -- issue: https://github.com/Kong/lua-resty-aws/issues/57 + local hostPrefix = "" + if operation.endpoint then + hostPrefix = operation.endpoint.hostPrefix + service.config.endpoint = hostPrefix .. service.config.endpoint + end + local operation_prefix = ("%s:%s()"):format( service.api.metadata.serviceId:gsub(" ",""), method_name) From 92ed5e8ec3e9686bd75b5f6dc43ff1fa2cf99280 Mon Sep 17 00:00:00 2001 From: Keery Nie Date: Mon, 15 Jan 2024 16:11:33 +0800 Subject: [PATCH 2/2] Update src/resty/aws/init.lua --- src/resty/aws/init.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/resty/aws/init.lua b/src/resty/aws/init.lua index 212a093..95e80e8 100644 --- a/src/resty/aws/init.lua +++ b/src/resty/aws/init.lua @@ -299,11 +299,8 @@ local function generate_service_methods(service) -- add hostPrefix for the methods that needs hostPrefix -- issue: https://github.com/Kong/lua-resty-aws/issues/57 - local hostPrefix = "" - if operation.endpoint then - hostPrefix = operation.endpoint.hostPrefix - service.config.endpoint = hostPrefix .. service.config.endpoint - end + local hostPrefix = operation.endpoint and operation.endpoint.hostPrefix or "" + service.config.endpoint = hostPrefix .. service.config.endpoint local operation_prefix = ("%s:%s()"):format( service.api.metadata.serviceId:gsub(" ",""),