Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
support overriding event type (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelvillard authored Mar 3, 2020
1 parent 9b3ad64 commit a49a7c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/appender/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ https://knative.dev/docs/eventing/sequence/
*/

type envConfig struct {
Msg string `envconfig:"MESSAGE" default:"boring default msg, change me with env[MESSAGE]"`
Msg string `envconfig:"MESSAGE" default:"boring default msg, change me with env[MESSAGE]"`
Type string `envconfig:"TYPE"`
}

var (
Expand Down Expand Up @@ -73,6 +74,11 @@ func gotEvent(event cloudevents.Event, resp *cloudevents.EventResponse) error {
Data: data,
}

// Resolve type
if env.Type != "" {
r.Context.SetType(env.Type)
}

r.SetDataContentType(cloudevents.ApplicationJSON)

log.Println("Transform the event to: ")
Expand Down

0 comments on commit a49a7c7

Please sign in to comment.