Skip to content

Commit 4d79e11

Browse files
committed
http binary wip
Signed-off-by: Fabio José <[email protected]>
1 parent 63d25f5 commit 4d79e11

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

lib/bindings/http/binary_0_1.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ HTTPBinary.prototype.emit = function(cloudevent){
1818
_headers["Content-Type"] = cloudevent.getContenttype();
1919

2020
_headers["CE-EventType"] = cloudevent.getType();
21+
_headers["CE-CloudEventsVersion"] = cloudevent.getSpecversion();
22+
23+
_headers["CE-Source"] = cloudevent.getSource();
24+
_headers["CE-EventID"] = cloudevent.getId();
25+
_headers["CE-EventTime"] = cloudevent.getTime();
26+
_headers["CE-SchemaURL"] = cloudevent.getSchemaurl();
2127

2228
// Set the cloudevent payload
2329
_config["data"] = cloudevent.format();

lib/cloudevent.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,37 @@ Cloudevent.prototype.source = function(_source){
4747
return this;
4848
};
4949

50+
Cloudevent.prototype.getSource = function(){
51+
return this.spec.getSource();
52+
};
53+
5054
Cloudevent.prototype.id = function(_id){
5155
this.spec.id(_id);
5256
return this;
5357
};
5458

59+
Cloudevent.prototype.getId = function() {
60+
return this.spec.getId();
61+
};
62+
5563
Cloudevent.prototype.time = function(_time){
5664
this.spec.time(_time);
5765
return this;
5866
};
5967

68+
Cloudevent.prototype.getTime = function() {
69+
return this.spec.getTime();
70+
};
71+
6072
Cloudevent.prototype.schemaurl = function(_schemaurl) {
6173
this.spec.schemaurl(_schemaurl);
6274
return this;
6375
};
6476

77+
Cloudevent.prototype.getSchemaurl = function() {
78+
return this.spec.getSchemaurl();
79+
};
80+
6581
Cloudevent.prototype.contenttype = function(_contenttype){
6682
this.spec.contenttype(_contenttype);
6783
return this;

lib/specs/spec_0_1.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,37 @@ Spec01.prototype.source = function(_source){
5555
return this;
5656
};
5757

58+
Spec01.prototype.getSource = function() {
59+
return this.payload["source"];
60+
};
61+
5862
Spec01.prototype.id = function(_id){
5963
this.payload["eventID"] = _id;
6064
return this;
6165
};
6266

67+
Spec01.prototype.getId = function() {
68+
return this.payload["eventID"];
69+
};
70+
6371
Spec01.prototype.time = function(_time){
6472
this.payload["eventTime"] = _time.toISOString();
6573
return this;
6674
};
6775

76+
Spec01.prototype.getTime = function() {
77+
return this.payload["eventTime"];
78+
};
79+
6880
Spec01.prototype.schemaurl = function(_schemaurl){
6981
this.payload["schemaURL"] = _schemaurl;
7082
return this;
7183
};
7284

85+
Spec01.prototype.getSchemaurl = function() {
86+
return this.payload["schemaURL"];
87+
};
88+
7389
Spec01.prototype.contenttype = function(_contenttype){
7490
this.payload["contentType"] = _contenttype;
7591
return this;

lib/specs/spec_0_2.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,28 @@ Spec02.prototype.id = function(_id){
5454
return this;
5555
};
5656

57+
Spec02.prototype.getId = function() {
58+
return this.payload["id"];
59+
};
60+
5761
Spec02.prototype.time = function(_time){
5862
this.payload["time"] = _time.toISOString();
5963
return this;
6064
};
6165

66+
Spec02.prototype.getTime = function() {
67+
return this.payload["time"];
68+
};
69+
6270
Spec02.prototype.schemaurl = function(_schemaurl){
6371
this.payload["schemaurl"] = _schemaurl;
6472
return this;
6573
};
6674

75+
Spec02.prototype.getSchemaurl = function() {
76+
return this.payload["schemaurl"];
77+
};
78+
6779
Spec02.prototype.contenttype = function(_contenttype){
6880
this.payload["contenttype"] = _contenttype;
6981
return this;

test/http_binding_0_1.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const type = "com.github.pull.create";
66
const source = "urn:event:from:myapi/resourse/123";
77
const webhook = "https://cloudevents.io/webhook";
88
const contentType = "application/cloudevents+json; charset=utf-8";
9+
const now = new Date();
10+
const schemaurl = "http://cloudevents.io/schema.json"
911

1012
const ceContentType = "application/json";
1113

@@ -21,6 +23,8 @@ var cloudevent =
2123
.type(type)
2224
.source(source)
2325
.contenttype(ceContentType)
26+
.time(now)
27+
.schemaurl(schemaurl)
2428
.data(data);
2529

2630
var httpcfg = {

0 commit comments

Comments
 (0)