Skip to content

Support Signature Type: CloudEvent #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grant opened this issue May 28, 2020 · 2 comments · Fixed by #29
Closed

Support Signature Type: CloudEvent #27

grant opened this issue May 28, 2020 · 2 comments · Fixed by #29
Assignees

Comments

@grant
Copy link
Contributor

grant commented May 28, 2020

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.


@grant
Copy link
Contributor Author

grant commented Jun 24, 2020

Reopened due to revert: #32

@grant
Copy link
Contributor Author

grant commented Aug 20, 2020

@juliehockett we can close with #36 landing right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants