File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed
samples/http/receiver-gin Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,7 @@ An example of a Gin webframework CloudEvents receiver with a [TektonEvent](https
88Get dependencies
99``` shell
1010cd samples/
11- go get github.com/gin-gonic/gin
12- go get github.com/rs/zerolog/log
11+ go get
1312
1413```
1514
@@ -18,11 +17,11 @@ Run the app
1817 go run main.go
1918```
2019
21- Test a CloudEvent
20+ Send a CloudEvent
2221``` shell
2322curl -v \
2423 -H " Ce-Id: e7d95c20-6eb4-4614-946d-27b0ce41c7ff" \
25- -H " Ce-Source: /apis/// namespaces/dimitar/ /clone-build-n4qhgl" \
24+ -H " Ce-Source: /apis/namespaces/dimitar/clone-build-n4qhgl" \
2625 -H " Ce-Subject: clone-build-n4qhgl" \
2726 -H " Ce-Specversion: 1.0" \
2827 -H " Ce-Type: dev.tekton.event.pipelinerun.started.v1" \
@@ -39,7 +38,7 @@ Logs output
3938Got an Event: Context Attributes,
4039 specversion: 1.0
4140 type: dev.tekton.event.pipelinerun.started.v1
42- source: /apis/// namespaces/dimitar/ /clone-build-n4qhgl
41+ source: /apis/namespaces/dimitar/clone-build-n4qhgl
4342 subject: clone-build-n4qhgl
4443 id: e7d95c20-6eb4-4614-946d-27b0ce41c7ff
4544 datacontenttype: application/json
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import (
1010 "github.com/gin-gonic/gin"
1111)
1212
13- func receiveTektonEvent (event cloudevents.Event ) {
13+ func receive (event cloudevents.Event ) {
1414 fmt .Printf ("Got an Event: %s" , event )
1515}
1616
@@ -23,7 +23,6 @@ func healthz(c *gin.Context) {
2323}
2424
2525func cloudEventsHandler () gin.HandlerFunc {
26-
2726 return func (c * gin.Context ) {
2827 p , err := cloudevents .NewHTTP ()
2928 if err != nil {
@@ -32,7 +31,7 @@ func cloudEventsHandler() gin.HandlerFunc {
3231 Msg ("Failed to create protocol" )
3332 }
3433
35- ceh , err := cloudevents .NewHTTPReceiveHandler (c , p , receiveTektonEvent )
34+ ceh , err := cloudevents .NewHTTPReceiveHandler (c , p , receive )
3635 if err != nil {
3736 log .Fatal ().
3837 Err (err ).
@@ -44,7 +43,6 @@ func cloudEventsHandler() gin.HandlerFunc {
4443}
4544
4645func main () {
47-
4846 r := gin .Default ()
4947 r .SetTrustedProxies (nil )
5048
You can’t perform that action at this time.
0 commit comments