Documentation
¶
Overview ¶
Package common has what the webhook protocols share: their bodies as JSON values, signatures compared in constant time, and a JSON object's fields
Index ¶
- func Decode(header http.Header, body []byte) (json.RawMessage, error)
- func Equal(signature, expected []byte) bool
- func EqualString(a, b string) bool
- func Field(values json.RawMessage, path ...string) string
- func HMAC(secret string, data ...[]byte) []byte
- func MediaType(header http.Header) string
- func NoSecret() error
- func Sample(fields map[string]any) (http.Header, []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode returns the body as JSON values: as it is, when it's JSON, an object of its fields, when it's a form, whose fields with more than one value are arrays, a string, when it's other text, or nil, when it's empty, or isn't text
func Equal ¶
Equal returns whether the signature, which isn't empty, is the expected one, in constant time
func EqualString ¶
EqualString returns whether the strings, the first of which isn't empty, are equal, in constant time
func Field ¶
func Field(values json.RawMessage, path ...string) string
Field returns the field of the JSON object, at the path, such as msg, id, as text, when it's a string, or a number, as it was sent, or empty, when it isn't one
func MediaType ¶
MediaType returns the media type of the Content-Type header, without its parameters, or empty
Types ¶
This section is empty.