lamby 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +1 -1
- data/lib/lamby.rb +0 -1
- data/lib/lamby/debug.rb +8 -1
- data/lib/lamby/rack.rb +11 -1
- data/lib/lamby/rack_alb.rb +1 -1
- data/lib/lamby/rack_http.rb +6 -2
- data/lib/lamby/ssm_parameter_store.rb +6 -5
- data/lib/lamby/templates/alb.rb +1 -1
- data/lib/lamby/templates/http.rb +1 -1
- data/lib/lamby/templates/rest.rb +1 -1
- data/lib/lamby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c79ddbdbe89366400b406896007cc36bac36cbe640d8485b3c33f87aaddb169
|
4
|
+
data.tar.gz: b1be59cec48ed5ce9c32b4f6275230b4cb266f1d35119706e50c93f520c58b79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf32a0550fa045d46af392932b57b5e3bb1e51155f6641225f06bbd89e2252635affb5733a51d753a18cd215cb0ade070d96c47c694f42eb864f9b30a597005
|
7
|
+
data.tar.gz: 796122743e00d8322364c58e34555ba4355698965aa452b389c707440d86777f2a508cb4325120b0e35105570a3b24c4b7993d28cfdc22f9c9f8e69773341ae4
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,20 @@
|
|
3
3
|
|
4
4
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
5
5
|
|
6
|
+
## v2.2.0
|
7
|
+
|
8
|
+
#### Changed
|
9
|
+
|
10
|
+
* Remove dependency on `activesupport` for rack-only applications.
|
11
|
+
* Remove ActiveSupport artifacts:
|
12
|
+
- Replace `strip_heredoc` with `<<~HEREDOC`.
|
13
|
+
- Remove instances of `Object#try`, replace with `&.`.
|
14
|
+
- Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
|
15
|
+
- Replace `Object#present?` with `to_s.empty?`.
|
16
|
+
- Replace `Array.wrap` with `Array[obj].compact.flatten`.
|
17
|
+
* Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
|
18
|
+
variables prior to enabling debug mode.
|
19
|
+
|
6
20
|
## v2.1.0
|
7
21
|
|
8
22
|
#### Changed
|
@@ -29,7 +43,7 @@ Support for new API Gateway HTTP APIs!!!
|
|
29
43
|
|
30
44
|
#### Added
|
31
45
|
|
32
|
-
* New
|
46
|
+
* New rack handler for HTTP API v1 and v2.
|
33
47
|
* Lots of backfill tests for, ALBs & REST APIs.
|
34
48
|
|
35
49
|
|
data/Gemfile.lock
CHANGED
data/lib/lamby.rb
CHANGED
data/lib/lamby/debug.rb
CHANGED
@@ -6,7 +6,7 @@ module Lamby
|
|
6
6
|
|
7
7
|
def on?(event)
|
8
8
|
params = event['multiValueQueryStringParameters'] || event['queryStringParameters']
|
9
|
-
(
|
9
|
+
(development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1'
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(event, context, env)
|
@@ -42,5 +42,12 @@ module Lamby
|
|
42
42
|
HTML
|
43
43
|
end
|
44
44
|
|
45
|
+
def development?
|
46
|
+
ENV
|
47
|
+
.slice('RACK_ENV', 'RAILS_ENV')
|
48
|
+
.values
|
49
|
+
.any? { |v| v.to_s.casecmp('development').zero? }
|
50
|
+
end
|
51
|
+
|
45
52
|
end
|
46
53
|
end
|
data/lib/lamby/rack.rb
CHANGED
@@ -71,10 +71,20 @@ module Lamby
|
|
71
71
|
value.map{ |v| "#{key}=#{v}" }.join('&')
|
72
72
|
end.flatten.join('&')
|
73
73
|
else
|
74
|
-
|
74
|
+
build_query_string
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def build_query_string
|
79
|
+
return if event['queryStringParameters'].nil?
|
80
|
+
|
81
|
+
Rack::Utils.build_nested_query(
|
82
|
+
event.fetch('queryStringParameters')
|
83
|
+
)
|
84
|
+
.gsub('[', '%5B')
|
85
|
+
.gsub(']', '%5D')
|
86
|
+
end
|
87
|
+
|
78
88
|
def base64_encoded?
|
79
89
|
event['isBase64Encoded']
|
80
90
|
end
|
data/lib/lamby/rack_alb.rb
CHANGED
@@ -11,7 +11,7 @@ module Lamby
|
|
11
11
|
|
12
12
|
def response(handler)
|
13
13
|
hhdrs = handler.headers
|
14
|
-
multivalue_headers = hhdrs.transform_values { |v| Array.
|
14
|
+
multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten } if multi_value?
|
15
15
|
status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
|
16
16
|
base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
|
17
17
|
body = Base64.strict_encode64(handler.body) if base64_encode
|
data/lib/lamby/rack_http.rb
CHANGED
@@ -38,8 +38,8 @@ module Lamby
|
|
38
38
|
|
39
39
|
def env_headers
|
40
40
|
super.tap do |hdrs|
|
41
|
-
if
|
42
|
-
hdrs[HTTP_COOKIE] =
|
41
|
+
if cookies.any?
|
42
|
+
hdrs[HTTP_COOKIE] = cookies.join('; ')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -48,6 +48,10 @@ module Lamby
|
|
48
48
|
event.dig('requestContext', 'http', 'method') || event['httpMethod']
|
49
49
|
end
|
50
50
|
|
51
|
+
def cookies
|
52
|
+
event['cookies'] || []
|
53
|
+
end
|
54
|
+
|
51
55
|
# Using custom domain names with v1.0 yields a good `path` parameter sans
|
52
56
|
# stage. However, v2.0 and others do not. So we are just going to remove stage
|
53
57
|
# no matter waht from other places for both.
|
@@ -19,9 +19,10 @@ module Lamby
|
|
19
19
|
parts = path.from(1).split('/')
|
20
20
|
env = parts.pop
|
21
21
|
path = "/#{parts.join('/')}"
|
22
|
-
new(path).get!.params.detect do |p|
|
22
|
+
param = new(path).get!.params.detect do |p|
|
23
23
|
p.env == env
|
24
|
-
end
|
24
|
+
end
|
25
|
+
param&.value
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
@@ -44,7 +45,7 @@ module Lamby
|
|
44
45
|
|
45
46
|
def get!
|
46
47
|
get_all!
|
47
|
-
get_history!
|
48
|
+
get_history! unless label.to_s.empty?
|
48
49
|
self
|
49
50
|
end
|
50
51
|
|
@@ -98,7 +99,7 @@ module Lamby
|
|
98
99
|
with_decryption: true,
|
99
100
|
max_results: MAX_RESULTS
|
100
101
|
}.tap { |options|
|
101
|
-
token = @all_response
|
102
|
+
token = @all_response&.next_token
|
102
103
|
options[:next_token] = token if token
|
103
104
|
}
|
104
105
|
end
|
@@ -137,7 +138,7 @@ module Lamby
|
|
137
138
|
with_decryption: true,
|
138
139
|
max_results: MAX_RESULTS
|
139
140
|
}.tap { |options|
|
140
|
-
token = @hist_response
|
141
|
+
token = @hist_response&.next_token
|
141
142
|
options[:next_token] = token if token
|
142
143
|
}
|
143
144
|
end
|
data/lib/lamby/templates/alb.rb
CHANGED
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
|
11
11
|
say 'Adding to .gitignore...'
|
12
12
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
13
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
14
|
# Lamby
|
15
15
|
/.aws-sam
|
16
16
|
GITIGNORE
|
data/lib/lamby/templates/http.rb
CHANGED
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
|
11
11
|
say 'Adding to .gitignore...'
|
12
12
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
13
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
14
|
# Lamby
|
15
15
|
/.aws-sam
|
16
16
|
GITIGNORE
|
data/lib/lamby/templates/rest.rb
CHANGED
@@ -10,7 +10,7 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
|
11
11
|
say 'Adding to .gitignore...'
|
12
12
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
13
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
14
|
# Lamby
|
15
15
|
/.aws-sam
|
16
16
|
GITIGNORE
|
data/lib/lamby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|