lamby 2.0.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -2
- data/lamby.gemspec +0 -1
- data/lib/lamby.rb +5 -3
- 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 +7 -6
- 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 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 149e90cb77c4ba7fa86e278f1b5faff11e271eec286de22564f423c7510b9b41
|
4
|
+
data.tar.gz: 804d1d2df7a4ed8f61b3d7fdde9ee8d3c73c9902d5b846ced5f39b4680b3f672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0911fda5872e2ea6b74c0fc0d358da8c641f89ebaf59c7ea143c62fb80baa35f5e0e301d21b4222535b42bdb0c3bad3d028083355321e0b8178d0b4e18b9c6c0'
|
7
|
+
data.tar.gz: 7d827e35e4c19f714ddfb30182d00d51b944513c9ccf667782218be2429eb397f27c0cfdc2737b00aa2c992075061c8e5b3e7fdad59be2efb9097542156311cf
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,46 @@
|
|
1
|
+
<!-- -*- mode: markdown -*- -->
|
1
2
|
# Keep A Changelog!
|
2
3
|
|
3
4
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
4
5
|
|
6
|
+
## v2.2.2
|
7
|
+
|
8
|
+
#### Changed
|
9
|
+
|
10
|
+
* More ActiveSupport removal. Better ENV.to_h.
|
11
|
+
|
12
|
+
## v2.2.1
|
13
|
+
|
14
|
+
#### Changed
|
15
|
+
|
16
|
+
* More ActiveSupport removal from SsmParameterStore.
|
17
|
+
|
18
|
+
## v2.2.0
|
19
|
+
|
20
|
+
#### Changed
|
21
|
+
|
22
|
+
* Remove dependency on `activesupport` for rack-only applications.
|
23
|
+
* Remove ActiveSupport artifacts:
|
24
|
+
- Replace `strip_heredoc` with `<<~HEREDOC`.
|
25
|
+
- Remove instances of `Object#try`, replace with `&.`.
|
26
|
+
- Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
|
27
|
+
- Replace `Object#present?` with `to_s.empty?`.
|
28
|
+
- Replace `Array.wrap` with `Array[obj].compact.flatten`.
|
29
|
+
* Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
|
30
|
+
variables prior to enabling debug mode.
|
31
|
+
|
32
|
+
## v2.1.0
|
33
|
+
|
34
|
+
#### Changed
|
35
|
+
|
36
|
+
* Only load the railtie if `Rails` is defined.
|
37
|
+
|
38
|
+
## v2.0.1
|
39
|
+
|
40
|
+
#### Changed
|
41
|
+
|
42
|
+
* Remove Rails runtime dep. Only rack is needed.
|
43
|
+
|
5
44
|
## v2.0.0
|
6
45
|
|
7
46
|
Support for new API Gateway HTTP APIs!!!
|
@@ -16,7 +55,7 @@ Support for new API Gateway HTTP APIs!!!
|
|
16
55
|
|
17
56
|
#### Added
|
18
57
|
|
19
|
-
* New
|
58
|
+
* New rack handler for HTTP API v1 and v2.
|
20
59
|
* Lots of backfill tests for, ALBs & REST APIs.
|
21
60
|
|
22
61
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/lamby.gemspec
CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
spec.add_dependency 'rack'
|
22
|
-
spec.add_dependency 'rails'
|
23
22
|
spec.add_development_dependency 'aws-sdk-ssm'
|
24
23
|
spec.add_development_dependency 'bundler'
|
25
24
|
spec.add_development_dependency 'rake'
|
data/lib/lamby.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'lamby/logger'
|
2
2
|
require 'rack'
|
3
3
|
require 'base64'
|
4
|
-
require 'active_support/all'
|
5
4
|
require 'lamby/version'
|
6
5
|
require 'lamby/sam_helpers'
|
7
6
|
require 'lamby/rack'
|
@@ -10,8 +9,11 @@ require 'lamby/rack_rest'
|
|
10
9
|
require 'lamby/rack_http'
|
11
10
|
require 'lamby/debug'
|
12
11
|
require 'lamby/handler'
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
if defined?(Rails)
|
14
|
+
require 'rails/railtie'
|
15
|
+
require 'lamby/railtie'
|
16
|
+
end
|
15
17
|
|
16
18
|
module Lamby
|
17
19
|
|
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.to_h
|
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.
|
@@ -16,12 +16,13 @@ module Lamby
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get!(path)
|
19
|
-
parts = path
|
19
|
+
parts = path[1..-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.2
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: aws-sdk-ssm
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|