Skip to content

Commit

Permalink
src,fix: drop support for v0.2 and clean up contenttype
Browse files Browse the repository at this point in the history
This commit removes support for the v0.2 specification. It also removes the
`contenttype` attribute from the `CloudEvent` object. While the HTTP protocol
binding specifies that in binary mode, the `datacontenttype` attribute should
map to the HTTP Content-Type header, that doesn't mean that the `CloudEvent`
object should have a `contenttype` property.

Fixes: #61
Fixes: #66

Signed-off-by: Lance Ball <lball@redhat.com>
  • Loading branch information
lance authored and fabiojose committed Apr 28, 2020
1 parent 1a4bdce commit 5110ad4
Show file tree
Hide file tree
Showing 35 changed files with 201 additions and 2,492 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To see working examples, point to [examples](./examples).

## :newspaper: Newsletter :newspaper:

> all the API developed before, for 0.1, 0.2 and 0.3, works as the same.
> all the API developed before, for 0.1 and 0.3, works as the same.
Checkout the new expressive additions.

Expand Down Expand Up @@ -91,21 +91,21 @@ These are the supported specifications by this version.

| **Specifications** | v0.1 | v0.2 | v0.3 | **v1.0** |
|---------------------------------------|------|------|------|----------|
| CloudEvents | yes | yes | yes | yes |
| HTTP Transport Binding - Structured | yes | yes | yes | yes |
| HTTP Transport Binding - Binary | yes | yes | yes | yes |
| JSON Event Format | yes | yes | yes | yes |
| CloudEvents | no | no | yes | yes |
| HTTP Transport Binding - Structured | no | no | yes | yes |
| HTTP Transport Binding - Binary | no | no | yes | yes |
| JSON Event Format | no | no | yes | yes |

### What we can do

| **What** | v0.1 | v0.2 | v0.3 | **v1.0** |
|-------------------------------------|--------|------|------|----------|
| Create events | yes | yes | yes | yes |
| Emit Structured events over HTTP | yes | yes | yes | yes |
| Emit Binary events over HTTP | yes | yes | yes | yes |
| JSON Event Format | yes | yes | yes | yes |
| Receive Structured events over HTTP | **no** | yes | yes | yes |
| Receive Binary events over HTTP | **no** | yes | yes | yes |
| Create events | no | no | yes | yes |
| Emit Structured events over HTTP | no | no | yes | yes |
| Emit Binary events over HTTP | no | no | yes | yes |
| JSON Event Format | no | no | yes | yes |
| Receive Structured events over HTTP | **no** | no | yes | yes |
| Receive Binary events over HTTP | **no** | no | yes | yes |

## How to use

Expand Down
58 changes: 0 additions & 58 deletions examples/express-ex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,61 +161,3 @@ __A Batch One__

TODO

## Spec v0.2

### How To Post an Event

__A Structured One__

> Payload [example](../payload/v02/structured-event-0.json)
```bash
curl -X POST \
-d'@../payload/v02/structured-event-0.json' \
-H'Content-Type:application/cloudevents+json' \
http://localhost:3000/v02
```

__A Structured One with Extension__

> Payload [example](../payload/v02/structured-event-1.json)
```bash
curl -X POST \
-d'@../payload/v02/structured-event-1.json' \
-H'Content-Type:application/cloudevents+json' \
http://localhost:3000/v02
```

__A Binary One__

```bash
curl -X POST \
-d'@../payload/data-0.json' \
-H'Content-Type:application/json' \
-H'ce-specversion:0.2' \
-H'ce-type:com.github.pull.create' \
-H'ce-source:https://github.com/cloudevents/spec/pull/123' \
-H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
-H'ce-time:2019-06-21T17:31:00Z' \
http://localhost:3000/v02
```

__A Binary One with Extension__

```bash
curl -X POST \
-d'@../payload/data-0.json' \
-H'Content-Type:application/json' \
-H'ce-specversion:0.2' \
-H'ce-type:com.github.pull.create' \
-H'ce-source:https://github.com/cloudevents/spec/pull/123' \
-H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
-H'ce-time:2019-06-21T17:31:00Z' \
-H'ce-my-extension:extension value' \
http://localhost:3000/v02
```

__A Batch One__

TODO
24 changes: 0 additions & 24 deletions examples/express-ex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const app = express();
const v03 = require("cloudevents-sdk/v03");
const unmarshaller03 = new v03.HTTPUnmarshaller();

const v02 = require("cloudevents-sdk/v02");
const unmarshaller02 = new v02.HTTPUnmarshaller();

const v1 = require("cloudevents-sdk/v1");
const structured1 = new v1.StructuredHTTPReceiver();
const binary1 = new v1.BinaryHTTPReceiver();
Expand Down Expand Up @@ -88,27 +85,6 @@ app.post("/v03", function(req, res) {
});
});

app.post("/v02", function(req, res) {
console.log(req.headers);
console.log(req.body);

unmarshaller02.unmarshall(req.body, req.headers)
.then((cloudevent) => {
// pretty print
console.log("Accepted event:");
console.log(JSON.stringify(cloudevent.format(), null, 2));

res.status(201)
.json(cloudevent.format());
})
.catch((err) => {
console.error(err);
res.status(415)
.header("Content-Type", "application/json")
.send(JSON.stringify(err));
});
});

app.listen(3000, function() {
console.log("Example app listening on port 3000!");
});
11 changes: 0 additions & 11 deletions examples/payload/v02/structured-event-0.json

This file was deleted.

14 changes: 0 additions & 14 deletions examples/payload/v02/structured-event-1.json

This file was deleted.

81 changes: 0 additions & 81 deletions ext/spec_0_2.json

This file was deleted.

3 changes: 0 additions & 3 deletions http/unmarshaller/v02.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/bindings/http/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
HEADERS: "headers",
CHARSET_DEFAULT: "utf-8",

SPEC_V02: "0.2",
SPEC_V03: "0.3",
SPEC_V1: "1.0",

Expand All @@ -23,26 +22,6 @@ module.exports = {
DEFAULT_CONTENT_TYPE: "application/json; charset=utf-8",
DEFAULT_CE_CONTENT_TYPE: "application/cloudevents+json; charset=utf-8",

BINARY_HEADERS_02: {
TYPE: "ce-type",
SPEC_VERSION: "ce-specversion",
SOURCE: "ce-source",
ID: "ce-id",
TIME: "ce-time",
SCHEMA_URL: "ce-schemaurl",
EXTENSIONS_PREFIX: "ce-"
},
STRUCTURED_ATTRS_02: {
TYPE: "type",
SPEC_VERSION: "specversion",
SOURCE: "source",
ID: "id",
TIME: "time",
SCHEMA_URL: "schemaurl",
CONTENT_TYPE: "contenttype",
DATA: "data"
},

BINARY_HEADERS_03: {
TYPE: "ce-type",
SPEC_VERSION: "ce-specversion",
Expand Down
91 changes: 0 additions & 91 deletions lib/bindings/http/emitter_binary_0_1.js

This file was deleted.

Loading

0 comments on commit 5110ad4

Please sign in to comment.