forked from akrylysov/algnhsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
49 lines (42 loc) · 1.22 KB
/
options.go
File metadata and controls
49 lines (42 loc) · 1.22 KB
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
package algnhsa
import (
"strings"
)
type RequestType int
const (
RequestTypeAuto RequestType = iota
RequestTypeAPIGateway
RequestTypeALB
)
// Options holds the optional parameters.
type Options struct {
// RequestType sets the expected request type.
// By default algnhsa deduces the request type from the lambda function payload.
RequestType RequestType
// BinaryContentTypes sets content types that should be treated as binary types.
// The "*/* value makes algnhsa treat any content type as binary.
BinaryContentTypes []string
binaryContentTypeMap map[string]map[string]bool
// Use API Gateway PathParameters["proxy"] when constructing the request url.
// Strips the base path mapping when using a custom domain with API Gateway.
UseProxyPath bool
}
func (opts *Options) setBinaryContentTypeMap() {
var types = make(map[string]map[string]bool)
for _, fullContentType := range opts.BinaryContentTypes {
ctParts := strings.Split(fullContentType, "/")
var a, b string
if len(ctParts) != 2 {
a = fullContentType
b = "*"
} else {
a = ctParts[0]
b = ctParts[1]
}
if _, exists := types[a]; exists != true {
types[a] = map[string]bool{}
}
types[a][b] = true
}
opts.binaryContentTypeMap = types
}