You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: prototype cloudevent function signature type (#147)
* feat: prototype cloudevent function signature type
* fix: use SignatureType in helper message
* fix: inline checks for signature type
The type guards like `isHttpFunction` is only used one so it's better to just inline them.
* fix: Populate cloudevent.data from the incoming request
* fix: Remove unused test functions
* docs: Update comments and docs re. cloudevent signature type
* docs: minor README edits
* fix: Simplify test for cloudevent functions
* docs: use relative link to `cloudevents.md`
`--port`| `PORT` | The port on which the Functions Framework listens for requests. Default: `8080`
150
-
`--target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function`
151
-
`--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event`
152
-
`--source` | `FUNCTION_SOURCE` | The path to the directory of your function. Default: `cwd` (the current working directory)
146
+
|Command-line flag | Environment variable| Description |
|`--port`|`PORT`| The port on which the Functions Framework listens for requests. Default: `8080`|
149
+
|`--target`|`FUNCTION_TARGET`| The name of the exported function to be invoked in response to requests. Default: `function`|
150
+
|`--signature-type`|`FUNCTION_SIGNATURE_TYPE`| The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` or `cloudevent`|
151
+
|`--source`|`FUNCTION_SOURCE`| The path to the directory of your function. Default: `cwd` (the current working directory)|
153
152
154
153
You can set command-line flags in your `package.json` via the `start` script.
155
154
For example:
@@ -160,12 +159,12 @@ For example:
160
159
}
161
160
```
162
161
163
-
# Enable CloudEvents
162
+
# Enable Google Cloud Functions Events
164
163
165
164
The Functions Framework can unmarshall incoming
166
-
[CloudEvents](http://cloudevents.io) payloads to `data` and `context` objects.
165
+
Google Cloud Functions [event](https://cloud.google.com/functions/docs/concepts/events-triggers#events) payloads to `data` and `context` objects.
167
166
These will be passed as arguments to your function when it receives a request.
168
-
Note that your function must use the event-style function signature:
167
+
Note that your function must use the `event`-style function signature:
169
168
170
169
```js
171
170
exports.helloEvents= (data, context) => {
@@ -182,6 +181,29 @@ For more details on this signature type, check out the Google Cloud Functions
[CloudEvents](http://cloudevents.io) payloads to a `cloudevent` object.
188
+
It will be passed as an argument to your function when it receives a request.
189
+
Note that your function must use the `cloudevent`-style function signature:
190
+
191
+
```js
192
+
exports.helloCloudEvents= (cloudevent) => {
193
+
console.log(cloudevent.specversion);
194
+
console.log(cloudevent.type);
195
+
console.log(cloudevent.source);
196
+
console.log(cloudevent.subject);
197
+
console.log(cloudevent.id);
198
+
console.log(cloudevent.time);
199
+
console.log(cloudevent.datacontenttype);
200
+
};
201
+
```
202
+
203
+
To enable CloudEvents, set the signature type to `cloudevent`. By default, the HTTP signature will be used and automatic event unmarshalling will be disabled.
204
+
205
+
Learn how to use CloudEvents in this [guide](docs/cloudevents.md).
206
+
185
207
# Advanced Docs
186
208
187
209
More advanced guides and docs can be found in the [`docs/` folder](docs/).
0 commit comments