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

Commit bf63bce

Browse files
authored
Merge pull request #42 from triggermesh/content-type-fix
Content-type verification fix
2 parents 4cb9a5f + dfe6f7e commit bf63bce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/converter/cloudevents/cloudevents.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,16 @@ func (ce *CloudEvent) Request(request []byte, headers http.Header) ([]byte, map[
127127
var body []byte
128128
var err error
129129

130-
switch headers.Get("Content-Type") {
131-
case "application/cloudevents+json":
130+
contentType := headers.Get("Content-Type")
131+
132+
if strings.HasPrefix(contentType, "application/cloudevents+json") {
132133
if body, context, err = parseStructuredCE(request); err != nil {
133134
return nil, nil, fmt.Errorf("structured CloudEvent parse error: %w", err)
134135
}
135-
case "application/json":
136+
} else if strings.HasPrefix(contentType, "application/json") {
136137
body = request
137138
context = parseBinaryCE(headers)
138-
default:
139+
} else {
139140
return request, nil, nil
140141
}
141142

0 commit comments

Comments
 (0)