mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-10 23:57:34 +02:00
replace GetAllPages with InitialSync, improve merge performance (#1624)
* replace GetAllPages with InitialSync, improve merge performance * fmt proto * add test for base64 function * add sync test * go mod tidy Co-authored-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
ba55fec67c
commit
aad8ac2e61
10 changed files with 298 additions and 214 deletions
23
internal/encoding/base64.go
Normal file
23
internal/encoding/base64.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package encoding
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DecodeBase64OrJSON decodes a JSON string that can optionally be base64 encoded.
|
||||
func DecodeBase64OrJSON(in string, out interface{}) error {
|
||||
in = strings.TrimSpace(in)
|
||||
|
||||
// the data can be base64 encoded
|
||||
if !json.Valid([]byte(in)) {
|
||||
bs, err := base64.StdEncoding.DecodeString(in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
in = string(bs)
|
||||
}
|
||||
|
||||
return json.Unmarshal([]byte(in), out)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue