This repository was archived by the owner on Dec 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff 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
7982type 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 }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import (
1111// CloudEvent is a data structure required to map KLR responses to cloudevents
1212type 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
You can’t perform that action at this time.
0 commit comments