serverless-rack 1.0.2 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +15 -3
- data/lib/serverless_rack.rb +20 -16
- data/serverless-rack.gemspec +4 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d054df889e1a091b14b03de69cd43fba9186fd0b7c126f036e32a7c581f230da
|
4
|
+
data.tar.gz: f03682869870aafd564e76ad6d8ff54a88eeec164152dd6e1e0584348c57d518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffa6d4107b258984e244d5fee0a0a2b870faee2d4b72fd3fd97cb2347ed40fba687426bfbcf106e5ce6cd9045e67842f1d5ffac2ef830b2ab4279c9f67d601e4
|
7
|
+
data.tar.gz: 10e61fa0152cdbc561e9dfb09de252377228af59d1df691c2783ad9ba1a320f84843b616651dce5485be5079d85b518e202ef4375e82fff42111367ae0f3b11c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
# 1.0.7
|
2
|
+
|
3
|
+
- Improved error handling for Docker processes (#20 and #21)
|
4
|
+
|
5
|
+
_Shalvah_
|
6
|
+
|
7
|
+
# 1.0.6
|
8
|
+
|
9
|
+
- Upgrade dependencies
|
10
|
+
- Add a dockerImage config option to override the docker image to be used for compiling gems (defaults to the lambci ruby images) (#17)
|
11
|
+
|
12
|
+
_Benjamin Curtis_
|
13
|
+
|
14
|
+
- Cache the bundle that is created by docker to avoid recompiling gems (#17)
|
15
|
+
|
16
|
+
_Benjamin Curtis_
|
17
|
+
|
18
|
+
- Handle empty `API_GATEWAY_BASE_PATH` (#14)
|
19
|
+
|
20
|
+
_Joel Van Horn_
|
21
|
+
|
22
|
+
# 1.0.5
|
23
|
+
|
24
|
+
- Upgrade dependencies
|
25
|
+
|
26
|
+
# 1.0.4
|
27
|
+
|
28
|
+
- Support `configPath` option when invoking `sls rack serve` (#5)
|
29
|
+
|
30
|
+
# 1.0.3
|
31
|
+
|
32
|
+
- Upgrade dependencies
|
33
|
+
|
1
34
|
# 1.0.2
|
2
35
|
|
3
36
|
- Remove `BUNDLED WITH` from Gemfile to allow using different version of
|
data/README.md
CHANGED
@@ -139,13 +139,23 @@ For more information, see https://bundler.io/docs.html.
|
|
139
139
|
|
140
140
|
If your application depends on any gems that include compiled binaries, these
|
141
141
|
must be compiled for the lambda execution environment. Enabling the `dockerizeBundler` configuration
|
142
|
-
option will fetch and build the gems using a
|
143
|
-
that emulates the lambda environment:
|
142
|
+
option will fetch and build the gems using a docker image that emulates the lambda environment:
|
144
143
|
|
145
144
|
```yaml
|
146
145
|
custom:
|
147
146
|
rack:
|
148
|
-
dockerizeBundler:
|
147
|
+
dockerizeBundler: true
|
148
|
+
```
|
149
|
+
|
150
|
+
The default docker image that will be used will match the runtime you are using.
|
151
|
+
That is, if you are using the `ruby2.7` runtime, then the docker image will be
|
152
|
+
`logandk/serverless-rack-bundler:ruby2.7`. You can override the docker image with the
|
153
|
+
`dockerImage` configuration option:
|
154
|
+
|
155
|
+
```yaml
|
156
|
+
custom:
|
157
|
+
rack:
|
158
|
+
dockerImage: lambci/lambda:build-ruby2.5
|
149
159
|
```
|
150
160
|
|
151
161
|
### Bundler configuration
|
@@ -219,6 +229,8 @@ $ sls rack serve -p 8000
|
|
219
229
|
When running locally, an environment variable named `IS_OFFLINE` will be set to `True`.
|
220
230
|
So, if you want to know when the application is running locally, check `ENV["IS_OFFLINE"]`.
|
221
231
|
|
232
|
+
For use with the `serverless-offline` plugin, run `sls rack install` prior to `sls offline`.
|
233
|
+
|
222
234
|
### Remote command execution
|
223
235
|
|
224
236
|
The `rack exec` command lets you execute ruby code remotely:
|
data/lib/serverless_rack.rb
CHANGED
@@ -15,17 +15,19 @@ TEXT_MIME_TYPES = [
|
|
15
15
|
'image/svg+xml'
|
16
16
|
].freeze
|
17
17
|
|
18
|
+
def base_path
|
19
|
+
"/#{ENV['API_GATEWAY_BASE_PATH']}" unless ENV['API_GATEWAY_BASE_PATH'].to_s.empty?
|
20
|
+
end
|
21
|
+
|
18
22
|
def keepalive_event?(event)
|
19
23
|
['aws.events', 'serverless-plugin-warmup'].include?(event['source'])
|
20
24
|
end
|
21
25
|
|
22
26
|
def parse_script_name(event, headers)
|
23
|
-
if
|
24
|
-
"/#{ENV['API_GATEWAY_BASE_PATH']}"
|
25
|
-
elsif (headers['Host'] || '').include?('amazonaws.com')
|
27
|
+
if base_path.nil? && (headers['Host'] || '').include?('amazonaws.com')
|
26
28
|
"/#{event['requestContext']['stage']}"
|
27
29
|
else
|
28
|
-
|
30
|
+
base_path.to_s
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -33,12 +35,11 @@ def parse_path_info(event)
|
|
33
35
|
# If a user is using a custom domain on API Gateway, they may have a base
|
34
36
|
# path in their URL. This allows us to strip it out via an optional
|
35
37
|
# environment variable.
|
36
|
-
if
|
37
|
-
|
38
|
-
|
38
|
+
if base_path && event['path'].start_with?(base_path)
|
39
|
+
event['path'][base_path.length..-1]
|
40
|
+
else
|
41
|
+
event['path']
|
39
42
|
end
|
40
|
-
|
41
|
-
event['path']
|
42
43
|
end
|
43
44
|
|
44
45
|
def parse_query_string(event)
|
@@ -59,9 +60,11 @@ end
|
|
59
60
|
|
60
61
|
def parse_headers(event)
|
61
62
|
if event.include? 'multiValueHeaders'
|
62
|
-
Rack::Utils::HeaderHash.new(
|
63
|
-
[
|
64
|
-
|
63
|
+
Rack::Utils::HeaderHash.new(
|
64
|
+
(event['multiValueHeaders'] || {}).transform_values do |value|
|
65
|
+
value.join("\n")
|
66
|
+
end
|
67
|
+
)
|
65
68
|
else
|
66
69
|
Rack::Utils::HeaderHash.new(event['headers'] || {})
|
67
70
|
end
|
@@ -166,11 +169,12 @@ end
|
|
166
169
|
|
167
170
|
def format_split_headers(headers:)
|
168
171
|
headers = headers.to_hash
|
172
|
+
keys = headers.keys
|
169
173
|
|
170
174
|
# If there are headers multiple occurrences, e.g. Set-Cookie, create
|
171
175
|
# case-mutated variations in order to pass them through APIGW.
|
172
176
|
# This is a hack that's currently needed.
|
173
|
-
|
177
|
+
keys.each do |key|
|
174
178
|
values = headers[key].split("\n")
|
175
179
|
|
176
180
|
next if values.size < 2
|
@@ -187,9 +191,9 @@ def format_split_headers(headers:)
|
|
187
191
|
end
|
188
192
|
|
189
193
|
def format_grouped_headers(headers:)
|
190
|
-
{ 'multiValueHeaders' => headers.
|
191
|
-
|
192
|
-
end
|
194
|
+
{ 'multiValueHeaders' => headers.transform_values do |value|
|
195
|
+
value.split("\n")
|
196
|
+
end }
|
193
197
|
end
|
194
198
|
|
195
199
|
def format_response(event:, status:, headers:, body:, text_mime_types:)
|
data/serverless-rack.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'serverless-rack'
|
3
|
-
s.version = '1.0.
|
5
|
+
s.version = '1.0.7'
|
4
6
|
s.summary =
|
5
7
|
'Serverless plugin to deploy Ruby Rack applications (Sinatra/Padrino/Cuba etc.) '\
|
6
8
|
'and bundle gems'
|
@@ -21,6 +23,6 @@ Gem::Specification.new do |s|
|
|
21
23
|
s.homepage = 'https://github.com/logandk/serverless-rack'
|
22
24
|
s.license = 'MIT'
|
23
25
|
|
24
|
-
s.required_ruby_version = '>= 2.
|
26
|
+
s.required_ruby_version = '>= 2.4.0'
|
25
27
|
s.add_dependency 'rack', '~> 2.0'
|
26
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverless-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Raarup
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -50,15 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.4.0
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
|
-
|
61
|
-
rubygems_version: 2.7.6
|
60
|
+
rubygems_version: 3.1.2
|
62
61
|
signing_key:
|
63
62
|
specification_version: 4
|
64
63
|
summary: Serverless plugin to deploy Ruby Rack applications (Sinatra/Padrino/Cuba
|