-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathcustomerheaders.go
More file actions
41 lines (31 loc) · 869 Bytes
/
customerheaders.go
File metadata and controls
41 lines (31 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package directinvoke
import (
"bytes"
"encoding/base64"
"encoding/json"
)
type CustomerHeaders struct {
CognitoIdentityID string `json:"Cognito-Identity-Id"`
CognitoIdentityPoolID string `json:"Cognito-Identity-Pool-Id"`
ClientContext string `json:"Client-Context"`
}
func (s CustomerHeaders) Dump() string {
if (s == CustomerHeaders{}) {
return ""
}
custHeadersJSON, err := json.Marshal(&s)
if err != nil {
panic(err)
}
return base64.StdEncoding.EncodeToString(custHeadersJSON)
}
func (s *CustomerHeaders) Load(in string) error {
*s = CustomerHeaders{}
if in == "" {
return nil
}
base64Decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewReader([]byte(in)))
return json.NewDecoder(base64Decoder).Decode(s)
}