mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-14 03:02:48 +01:00
21 lines
316 B
Go
21 lines
316 B
Go
package webhook
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"io"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
func EncodeBody(requestBody io.Reader) (string, bool) {
|
|
body, err := io.ReadAll(requestBody)
|
|
if err != nil {
|
|
return "", false
|
|
}
|
|
|
|
if utf8.Valid(body) {
|
|
return string(body), false
|
|
}
|
|
|
|
return base64.StdEncoding.EncodeToString(body), true
|
|
}
|