无服务器框架API网关Websockets二进制数据



有人知道如何在无服务器框架中将websocket的内容处理策略设置为二进制吗?

我有一个定义如下的websocket:

my_websocket:
handler: src/handler.handler
description: My websocket
events:
- websocket:
route: $default
- websocket:
route: $connect
- websocket:
route: $disconnect

我的处理程序需要二进制数据

https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-develop-binary-media-types.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-method-integration.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integrationresponse.html

我需要将我的ContentHandlingContentHandlingStrategy设置为CONVERT_TO_BINARY,但我不确定如何实现这一点。

这两个包似乎都不能处理websocket:

  • 无服务器apigw二进制
  • 无服务器apigwy二进制

设置任一道具(或两者)失败:

events:
- websocket:
route: $default
ContentHandling: CONVERT_TO_BINARY
ContentHandlingStrategy: CONVERT_TO_BINARY
- websocket:
route: $connect
ContentHandling: CONVERT_TO_BINARY
ContentHandlingStrategy: CONVERT_TO_BINARY
- websocket:
route: $disconnect
ContentHandling: CONVERT_TO_BINARY
ContentHandlingStrategy: CONVERT_TO_BINARY

如下所示:

Serverless: Configuration warning:
Serverless:   at 'functions.my_websocket.events[0].websocket': unrecognized property 'contentHandling'
Serverless:   at 'functions.my_websocket.events[0].websocket': unrecognized property 'ContentHandlingStrategy'
Serverless:   at 'functions.my_websocket.events[1].websocket': unrecognized property 'contentHandling'
Serverless:   at 'functions.my_websocket.events[1].websocket': unrecognized property 'ContentHandlingStrategy'
Serverless:   at 'functions.my_websocket.events[2].websocket': unrecognized property 'contentHandling'
Serverless:   at 'functions.my_websocket.events[2].websocket': unrecognized property 'ContentHandlingStrategy'

值得注意的是,这是可以实现的(由一个朋友)使用cdk如下:

const messageIntegration = new CfnIntegration(this, `${name}-message-route-lambda-integration`, {
apiId: api.ref,
integrationType: 'AWS_PROXY',
integrationUri: 'arn:aws:apigateway:' + config['region'] + ':lambda:path/2015-03-31/functions/' + messageFunc.functionArn + '/invocations',
credentialsArn: role.roleArn,
contentHandlingStrategy: 'CONVERT_TO_BINARY', // see http://amzn.to/39DkYP4
})

我正在寻找一种sls方法,因为我所有的基础设施都在sls中管理,我不想吸收技术债务迁移(除非我必须)

I"已解决";这是通过base64编码我的二进制数据并使用$default处理程序实现的,该处理程序允许任意数据类型的

相关内容

  • 没有找到相关文章

最新更新