File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ HTTPBinary.prototype.emit = function(cloudevent){
18
18
_headers [ "Content-Type" ] = cloudevent . getContenttype ( ) ;
19
19
20
20
_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 ( ) ;
21
27
22
28
// Set the cloudevent payload
23
29
_config [ "data" ] = cloudevent . format ( ) ;
Original file line number Diff line number Diff line change @@ -47,21 +47,37 @@ Cloudevent.prototype.source = function(_source){
47
47
return this ;
48
48
} ;
49
49
50
+ Cloudevent . prototype . getSource = function ( ) {
51
+ return this . spec . getSource ( ) ;
52
+ } ;
53
+
50
54
Cloudevent . prototype . id = function ( _id ) {
51
55
this . spec . id ( _id ) ;
52
56
return this ;
53
57
} ;
54
58
59
+ Cloudevent . prototype . getId = function ( ) {
60
+ return this . spec . getId ( ) ;
61
+ } ;
62
+
55
63
Cloudevent . prototype . time = function ( _time ) {
56
64
this . spec . time ( _time ) ;
57
65
return this ;
58
66
} ;
59
67
68
+ Cloudevent . prototype . getTime = function ( ) {
69
+ return this . spec . getTime ( ) ;
70
+ } ;
71
+
60
72
Cloudevent . prototype . schemaurl = function ( _schemaurl ) {
61
73
this . spec . schemaurl ( _schemaurl ) ;
62
74
return this ;
63
75
} ;
64
76
77
+ Cloudevent . prototype . getSchemaurl = function ( ) {
78
+ return this . spec . getSchemaurl ( ) ;
79
+ } ;
80
+
65
81
Cloudevent . prototype . contenttype = function ( _contenttype ) {
66
82
this . spec . contenttype ( _contenttype ) ;
67
83
return this ;
Original file line number Diff line number Diff line change @@ -55,21 +55,37 @@ Spec01.prototype.source = function(_source){
55
55
return this ;
56
56
} ;
57
57
58
+ Spec01 . prototype . getSource = function ( ) {
59
+ return this . payload [ "source" ] ;
60
+ } ;
61
+
58
62
Spec01 . prototype . id = function ( _id ) {
59
63
this . payload [ "eventID" ] = _id ;
60
64
return this ;
61
65
} ;
62
66
67
+ Spec01 . prototype . getId = function ( ) {
68
+ return this . payload [ "eventID" ] ;
69
+ } ;
70
+
63
71
Spec01 . prototype . time = function ( _time ) {
64
72
this . payload [ "eventTime" ] = _time . toISOString ( ) ;
65
73
return this ;
66
74
} ;
67
75
76
+ Spec01 . prototype . getTime = function ( ) {
77
+ return this . payload [ "eventTime" ] ;
78
+ } ;
79
+
68
80
Spec01 . prototype . schemaurl = function ( _schemaurl ) {
69
81
this . payload [ "schemaURL" ] = _schemaurl ;
70
82
return this ;
71
83
} ;
72
84
85
+ Spec01 . prototype . getSchemaurl = function ( ) {
86
+ return this . payload [ "schemaURL" ] ;
87
+ } ;
88
+
73
89
Spec01 . prototype . contenttype = function ( _contenttype ) {
74
90
this . payload [ "contentType" ] = _contenttype ;
75
91
return this ;
Original file line number Diff line number Diff line change @@ -54,16 +54,28 @@ Spec02.prototype.id = function(_id){
54
54
return this ;
55
55
} ;
56
56
57
+ Spec02 . prototype . getId = function ( ) {
58
+ return this . payload [ "id" ] ;
59
+ } ;
60
+
57
61
Spec02 . prototype . time = function ( _time ) {
58
62
this . payload [ "time" ] = _time . toISOString ( ) ;
59
63
return this ;
60
64
} ;
61
65
66
+ Spec02 . prototype . getTime = function ( ) {
67
+ return this . payload [ "time" ] ;
68
+ } ;
69
+
62
70
Spec02 . prototype . schemaurl = function ( _schemaurl ) {
63
71
this . payload [ "schemaurl" ] = _schemaurl ;
64
72
return this ;
65
73
} ;
66
74
75
+ Spec02 . prototype . getSchemaurl = function ( ) {
76
+ return this . payload [ "schemaurl" ] ;
77
+ } ;
78
+
67
79
Spec02 . prototype . contenttype = function ( _contenttype ) {
68
80
this . payload [ "contenttype" ] = _contenttype ;
69
81
return this ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ const type = "com.github.pull.create";
6
6
const source = "urn:event:from:myapi/resourse/123" ;
7
7
const webhook = "https://cloudevents.io/webhook" ;
8
8
const contentType = "application/cloudevents+json; charset=utf-8" ;
9
+ const now = new Date ( ) ;
10
+ const schemaurl = "http://cloudevents.io/schema.json"
9
11
10
12
const ceContentType = "application/json" ;
11
13
@@ -21,6 +23,8 @@ var cloudevent =
21
23
. type ( type )
22
24
. source ( source )
23
25
. contenttype ( ceContentType )
26
+ . time ( now )
27
+ . schemaurl ( schemaurl )
24
28
. data ( data ) ;
25
29
26
30
var httpcfg = {
You can’t perform that action at this time.
0 commit comments