-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathmessage_ext.go
More file actions
39 lines (35 loc) · 1.16 KB
/
message_ext.go
File metadata and controls
39 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package svix
import (
"github.com/svix/svix-webhooks/go/models"
)
// Instantiates a new MessageIn object with a raw string payload.
// The payload is not normalized on the server. Normally, payloads are required
// to be JSON, and Svix will minify the payload before sending the webhook
// (for example, by removing extraneous whitespace or unnecessarily escaped
// characters in strings). With this function, the payload will be sent
// "as is", without any minification or other processing.
//
// The `contentType` parameter can be used to change the `content-type` header
// of the webhook sent by Svix overriding the default of `application/json`.
//
// See the class documentation for details about the other parameters.
func NewMessageInRaw(
eventType string,
payload string,
contentType *string,
) *models.MessageIn {
msgIn := models.MessageIn{
EventType: eventType,
Payload: map[string]any{},
}
transformationsParams := map[string]interface{}{
"rawPayload": payload,
}
if contentType != nil {
transformationsParams["headers"] = map[string]string{
"content-type": *contentType,
}
}
msgIn.TransformationsParams = &transformationsParams
return &msgIn
}