mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-24 08:41:33 +00:00
27 lines
435 B
Go
27 lines
435 B
Go
package hook
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"reflect"
|
|
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
func Base64ToBytesHookFunc() mapstructure.DecodeHookFuncType {
|
|
return func(
|
|
f reflect.Type,
|
|
t reflect.Type,
|
|
data interface{},
|
|
) (interface{}, error) {
|
|
if f.Kind() != reflect.String {
|
|
return data, nil
|
|
}
|
|
|
|
if t != reflect.TypeOf([]byte{}) {
|
|
return data, nil
|
|
}
|
|
|
|
return base64.StdEncoding.DecodeString(data.(string))
|
|
}
|
|
}
|