在API网关Lambda代理返回非Base64编码的数据,您可以使用以下方法:
使用API网关集成响应模型:
#set($inputRoot = $input.path('$'))
{
"statusCode": $inputRoot.statusCode,
"body": "$inputRoot.body",
"headers": {
#foreach($header in $inputRoot.headers.entrySet())
"$header.key": "$header.value" #if($foreach.hasNext),#end
#end
}
}
在Lambda函数中手动返回非Base64编码的数据:
import json
def lambda_handler(event, context):
# 处理您的逻辑
response_data = "Your response data" # 非Base64编码的数据
# 构建响应对象
response = {
"statusCode": 200,
"body": response_data,
"headers": {
"Content-Type": "application/json"
}
}
# 返回响应对象
return response
这些方法可以帮助您在API网关Lambda代理中返回非Base64编码的数据。根据您的具体需求和使用的编程语言,您可以选择适合您的方法来实现。