-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.go
42 lines (34 loc) · 1023 Bytes
/
request.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
package godo
// Request - Represents the incoming Digital Ocean serverless request. Ideally
// the args parameter in the Main function should have this type.
//
// NOTE: The input to Main will be if called from the dashboard without
// populating the parameters field.
type Request map[string]interface{}
func (r Request) GetHeaders() map[string]interface{} {
return r["__ow_headers"].(map[string]interface{})
}
func (r Request) GetPath() string {
return r["__ow_path"].(string)
}
func (r Request) GetMethod() Method {
return r["__ow_method"].(Method)
}
func (r Request) GetBody() string {
return r["__ow_body"].(string)
}
func (r Request) GetQuery() string {
return r["__ow_query"].(string)
}
type Method string
const (
MethodHead Method = "head"
MethodGet Method = "get"
MethodPost Method = "post"
MethodPut Method = "put"
MethodDelete Method = "delete"
MethodConnect Method = "connect"
MethodOptions Method = "options"
MethodTrace Method = "trace"
MethodPatch Method = "patch"
)