google-cloud-functions - 使用 BODY 的 Google Cloud Functions 自定义 URL 重定向
问题描述
我正在使用具有自定义域的 Google Cloud Functions 来触发这些功能。然后我在执行过程中意识到了一些非常糟糕的事情。使用普通 URL ( https://us-central1-project.cloudfunctions.net/function
),我的请求会保留其标头和正文,我可以将数据发送到我的函数。
但是,使用 firebase 重定向后,所有请求都是文本/纯文本GET
请求,其中content-type
没有数据;完全是空的。
有没有一种方法可以在我的云函数中获取这些数据,同时仍然为我的函数使用自定义 URL?
在寻找这个时,我遇到了这个问题>>为谷歌云功能使用自定义域<<我回答了我如何添加我的自定义 URL。这正是我使用它的方式。
这是我的函数调试代码
def function(request)
content_type = request.headers['content-type']
data = "not processed"
if 'application/json' in content_type:
data = str( request.get_json(force=True) )
elif 'text/plain' in content_type:
data = request.data.decode()
else:
return redirect('https://tradingview.to')
print(data)
return data
解决方案
推荐阅读
- keras - 使用 PyTorch 的 DCGAN 判别器准确度指标
- javascript - 了解 debounce 函数逻辑流程,特别是对于 Event 对象 - (...args) 从哪里获取它的值?
- swift - 如何删除 UICollectionView 的 ContextMenu 的行分隔符?
- leaflet - 在区域内移动标记/标签以避免与 Leaflet 中的集群发生冲突
- c# - Azure Logic App Store Excel 电子邮件附件到 Blob、下载和阅读
- r - 如何在 ggplot2 中聚合连续直方图的值?
- security - 在没有列表权限的情况下向 S3 存储桶 URL 添加尾部斜杠会导致空文件下载而不是访问被拒绝
- java - 如何拦截 Apache AsyncHttpClient 中的请求?
- java - 如何在 JFreeChart XYLine 中设置不均匀(空格)刻度单位
- swagger-codegen - 自定义使用swagger codegen生成的Code的html和css