Skip to content

Support Signature Type: CloudEvent #29

Closed
@grant

Description

@grant

Support signature type cloudevent

This signature type should support HTTP requests with CloudEvent objects delivered via either structured and binary CloudEvent objects. Usually a CloudEvents SDK can handle transforming the HTTP request to a language-native CloudEvent object.

New signature cloudevent in Functions Framework contract

The end-user should see the parameter cloudevent, which is a native CloudEvent object using the CloudEvent SDK if possible.

Example User Experience (in Node)

function handler(cloudevent) {
  console.log(cloudevent.id);
  console.log(cloudevent.data.message);
  console.log(cloudevent.custom_values_should_be_accepted);
  return "anything"
}

Example HTTP requests

The CloudEvents specification requires support for both "binary" and "structured" encodings for CloudEvents delivered via HTTP. The Function Framework must support both encodings. A CloudEvents SDK might make this easier, but most SDKs are not complete, so logic may exist within the Framework.

Examples:

Binary content mode

POST /any/url/is/accepted HTTP/1.1
Host: example.com
ce-specversion: 1.0
ce-type: com.example.someevent
ce-time: 2018-04-05T03:56:24Z
ce-id: 1234-1234-1234
ce-source: /mycontext/subcontext
x-google-custom-header: 77
Content-Type: <contentType>
Content-Length: 33
{
    "message": "Hello World!"
}

Structured content mode

POST /someresource HTTP/1.1
Host: example.com
Content-Type: <contentType>
Content-Length: 266
{
    "specversion": "1.0",
    "type": "com.example.someevent",
    "time": "2018-04-05T03:56:24Z",
    "id": "1234-1234-1234",
    "source": "/mycontext/subcontext",
    "datacontenttype": "application/json",
    "data": {
        "message": "Hello World!"
    },
    "custom_values_should_be_accepted": 42
}

A user should be able to access all of the HTTP headers.
A user should be able to access the body of the CloudEvent in the data field of an object.


Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions