-
Notifications
You must be signed in to change notification settings - Fork 32
/
event.go
159 lines (124 loc) · 5.12 KB
/
event.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// Copyright 2017 Alsanium, SAS. or its affiliates. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Originally from https://github.com/eawsy/aws-lambda-go-event/blob/master/service/lambda/runtime/event/apigatewayproxyevt/definition.go
// Changes (kothar - 2017-02):
// Relocated to go-apex/proxy
package proxy
import "encoding/json"
// Identity provides identity information about the API caller.
type Identity struct {
// The API owner key associated with the API.
APIKey string
// The AWS account ID associated with the request.
AccountID string
// The User Agent of the API caller.
UserAgent string
// The source IP address of the TCP connection making the request to
// Amazon API Gateway.
SourceIP string
// The Amazon Access Key associated with the request.
AccessKey string
// The principal identifier of the caller making the request.
// It is same as the User and interchangeable.
Caller string
// The principal identifier of the user making the request.
// It is same as the Caller and interchangeable.
User string
// The Amazon Resource Name (ARN) of the effective user identified after
// authentication.
UserARN string
// The Amazon Cognito identity ID of the caller making the request.
// Available only if the request was signed with Amazon Cognito credentials.
CognitoIdentityID string
// The Amazon Cognito identity pool ID of the caller making the request.
// Available only if the request was signed with Amazon Cognito credentials.
CognitoIdentityPoolID string
// The Amazon Cognito authentication type of the caller making the request.
// Available only if the request was signed with Amazon Cognito credentials.
CognitoAuthenticationType string
// The Amazon Cognito authentication provider used by the caller making the
// request.
// Available only if the request was signed with Amazon Cognito credentials.
CognitoAuthenticationProvider string
}
// RequestContext provides contextual information about an Amazon API Gateway
// Proxy event.
type RequestContext struct {
// The identifier Amazon API Gateway assigns to the API.
APIID string
// The identifier Amazon API Gateway assigns to the resource.
ResourceID string
// An automatically generated ID for the API call.
RequestID string
// The incoming request HTTP method name.
// Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
HTTPMethod string
// The resource path as defined in Amazon API Gateway.
ResourcePath string
// The AWS account ID associated with the API.
AccountID string
// The deployment stage of the API call (for example, Beta or Prod).
Stage string
// The API caller identification information.
Identity *Identity
// If used with Amazon Cognito, it represents the claims returned from the
// Amazon Cognito user pool after the method caller is successfully
// authenticated.
// If used with Amazon API Gateway custom authorizer, it represents the
// specified key-value pair of the context map returned from the custom
// authorizer AWS Lambda function.
Authorizer map[string]string `json:"-"`
}
// Event represents an Amazon API Gateway Proxy Event.
type Event struct {
// The incoming request HTTP method name.
// Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
HTTPMethod string
// The incoming reauest HTTP headers.
// Duplicate entries are not supported.
Headers map[string]string
// The resource path with raw placeholders as defined in Amazon API Gateway.
Resource string
// The incoming request path parameters corresponding to the resource path
// placeholders values as defined in Resource.
PathParameters map[string]string
// The real path corresponding to the path parameters injected into the
// Resource placeholders.
Path string
// The incoming request query string parameters.
// Duplicate entries are not supported.
QueryStringParameters map[string]string
// If used with Amazon API Gateway binary support, it represents the Base64
// encoded binary data from the client.
// Otherwise it represents the raw data from the client.
Body string
// A flag to indicate if the applicable request payload is Base64 encoded.
IsBase64Encoded bool
// The name-value pairs defined as configuration attributes associated with
// the deployment stage of the API.
StageVariables map[string]string
// The contextual information associated with the API call.
RequestContext *RequestContext
}
// String returns the string representation.
func (e *Event) String() string {
s, _ := json.MarshalIndent(e, "", " ")
return string(s)
}
// GoString returns the string representation.
func (e *Event) GoString() string {
return e.String()
}