英文:
IntegrationResponse SAM Template
问题
-
IntegrationResponse to Sam template ? Is it possible without OpenApi?
- 将IntegrationResponse添加到SAM模板中?是否可以在没有OpenApi的情况下实现?
-
Way to add headers to GatewayResponses in SAM template?
- 在SAM模板中添加头部到GatewayResponses的方法是什么?
What im trying to achive:
- 我想要实现的目标是:
Define gateway responses and integration responses inside a SAM CloudFront template.
- 在SAM CloudFront模板中定义网关响应和集成响应。
What i checked so far:
- 我目前已经检查的内容有:
I was checking SAM github but for me it wasnt clear how to do it based on the above link. Also i didnt found any answer on stackoverflow which would explain why the headers are bad in my gatewayresponse snippet
- 我在检查SAM GitHub时,对于我来说不太清楚如何根据上面的链接来实现。而且我在Stack Overflow上也没有找到任何解释为什么我的网关响应片段中的头部有问题的答案。
Every Help is appreciated
- 感谢任何帮助。
Some examples:
Globals:
Api:
GatewayResponses:
MISSING_AUTHENTICATION_TOKEN:
ResponseParameters:
# gatewayresponse.header.Cache-Control: "no-cache"
ResponseTemplates:
"application/json" : '{"errors": [{errorKey: "error Value"}]}'
StatusCode: '404'
#defaultResponse: true
Expected function level integrationResponse:
Function:
Type: AWS::Serverless::Function
Properties:
Handler: Function.handler
Timeout: 20
CodeUri: "src/Function"
Role: .......
Events:
FunctionGet:
Type: Api
Properties:
Path: /Function
Method: get
IntegrationResponse:
SOME_ERROR_CODE
ResponseTemplates
integrationresponse.header
英文:
Questions:
- IntegrationResponse to Sam template ? Is it possible without OpenApi?
- Way to add headers to GatewayResponses in SAM template?
What im trying to achive:
- Define gateway responses and integration responses inside a SAM
CloudFront template.
What i checked so far:
I was checking SAM github but for me it wasnt clear how to do it based on the above link.
Also i didnt found any answer on stackoverflow which would explain why the headers are bad in my gatewayresponse snippet
Every Help is appreciated
Some examples:
Globals:
Api:
GatewayResponses:
MISSING_AUTHENTICATION_TOKEN:
ResponseParameters:
# gatewayresponse.header.Cache-Control: "no-cache"
ResponseTemplates:
"application/json" : '{"errors": [{errorKey: "error Value"}]}'
StatusCode: '404'
#defaultResponse: true
Expected function level integrationResponse:
Function:
Type: AWS::Serverless::Function
Properties:
Handler: Function.handler
Timeout: 20
CodeUri: "src/Function"
Role: .......
Events:
FunctionGet:
Type: Api
Properties:
Path: /Function
Method: get
IntegrationResponse:
SOME_ERROR_CODE
ResponseTemplates
integrationresponse.header
答案1
得分: 1
以下是翻译好的内容:
"So long story short half of my question is stupid. in proxy integration API GW is by defult returning the response from server to client no need further declaration in SAM template.
As for the headers the following way is the correct:
Globals:
Api:
GatewayResponses:
MISSING_AUTHENTICATION_TOKEN:
ResponseParameters:
Headers:
Access-Control-Allow-Origin: "''"
Access-Control-Allow-Headers: "''"
Cache-Control: "'no-cache'"
Content-Type: "'application/json'"
ResponseTemplates:
"application/json" : '{"errors": [{errorKey: "error Value"}]}'
StatusCode: '404'
#defaultResponse: true"
英文:
So long story short half of my question is stupid. in proxy integration API GW is by defult returning the response from server to client no need further declaration in SAM template.
As for the headers the following way is the correct:
Globals:
Api:
GatewayResponses:
MISSING_AUTHENTICATION_TOKEN:
ResponseParameters:
Headers:
Access-Control-Allow-Origin: "'*'"
Access-Control-Allow-Headers: "'*'"
Cache-Control: "'no-cache'"
Content-Type: "'application/json'"
ResponseTemplates:
"application/json" : '{"errors": [{errorKey: "error Value"}]}'
StatusCode: '404'
#defaultResponse: true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论