This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.11.5.3. 关于调用 Go 功能
当使用 Knative (kn
) CLI 创建功能项目时,您可以生成一个响应 CloudEvents 的项目,或者响应简单 HTTP 请求的项目。Go 函数通过不同的方法调用,具体取决于它们是由 HTTP 请求还是 CloudEvent 触发。
11.5.3.1. HTTP 请求触发的功能 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
收到传入的 HTTP 请求时,将通过标准 Go Context 作为第一个参数来调用函数,后跟 http.ResponseWriter
和 http.Request
参数。您可以使用标准 Go 技术访问请求,并为您的功能设置对应的 HTTP 响应。
HTTP 响应示例