lockserver/config/types.go
Finn 350fc3b339
All checks were successful
/ build-container (push) Successful in 1m3s
rip out all auth stuff, add a containerfile
2024-04-23 17:34:57 -07:00

37 lines
619 B
Go

package config
import (
"encoding/base64"
"encoding/json"
)
type JSONBytes []byte
func (j JSONBytes) MarshalJSON() ([]byte, error) {
return json.Marshal(base64.URLEncoding.EncodeToString(j))
}
func (j JSONBytes) String() string {
return base64.URLEncoding.EncodeToString(j)
}
func (j *JSONBytes) UnmarshalJSON(data []byte) error {
var str string
err := json.Unmarshal(data, &str)
if err != nil {
return err
}
parsed, err := base64.URLEncoding.DecodeString(str)
if err != nil {
return err
}
*j = JSONBytes(parsed)
return nil
}
func (j JSONBytes) AsByteArrayArray() []byte {
return []byte(j)
}