Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 88ea713

Browse files
committed
Option K_SINK support added
1 parent 6886122 commit 88ea713

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: main.go

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ type Specification struct {
7474
// NOTE: Response wrapper does both encoding and decoding depending on the type. We should consider
7575
// separating wrappers by their function.
7676
ResponseWrapper string `envconfig:"response_wrapper"`
77+
78+
// Optional sink reference
79+
Sink string `envconfig:"k_sink"`
7780
}
7881

7982
type message struct {
@@ -144,6 +147,14 @@ func (s *Specification) newTask(w http.ResponseWriter, r *http.Request) {
144147
w.Write([]byte(fmt.Sprintf("Deadline is reached, data %s", task.data)))
145148
case result := <-resultsChannel:
146149
log.Printf("-> %s %d %s\n", result.id, result.statusCode, result.data)
150+
if s.Sink != "" {
151+
ww := w
152+
ww.WriteHeader(result.statusCode)
153+
ww.Header().Set("HOST", s.Sink)
154+
ww.Write(result.data)
155+
156+
result.data = []byte("ok")
157+
}
147158
w.WriteHeader(result.statusCode)
148159
w.Write(result.data)
149160
}

Diff for: pkg/events/cloudevents/mapper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
// CloudEvent is a data structure required to map KLR responses to cloudevents
1212
type CloudEvent struct {
1313
EventType string `envconfig:"type" default:"ce.klr.triggermesh.io"`
14-
Source string `envconfig:"k_service" default:"knative-lambda-runtime"`
14+
Source string `envconfig:"source" default:"knative-lambda-runtime"`
1515
Subject string `envconfig:"subject" default:"klr-response"`
1616
}
1717

0 commit comments

Comments
 (0)