lamby 2.6.3 → 2.7.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 +6 -0
- data/Gemfile.lock +1 -1
- data/lib/lamby.rb +5 -0
- data/lib/lamby/config.rb +47 -0
- data/lib/lamby/handler.rb +17 -3
- data/lib/lamby/railtie.rb +0 -2
- data/lib/lamby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 898837f3efba1d03d1a66891a3c3292c2172aaa24f300775fb537f99e2270ff3
|
4
|
+
data.tar.gz: d6cf3bdd2428c566eff0089e153d44bfe3a9385c8d20fe16197e076574adc75d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a9c05316b430742811542f56e0655042ab0c67aa0d135a1cce019a9427a2a0480c6f10f7a5afa625cdfca3e5c6f2b7739a7ffc6e2f5b4f8beff1e0b2549fbb8
|
7
|
+
data.tar.gz: b7b93733799866aac121eabcc7924659ac14eb1e359dbc7afe8bd7f78e3ef559dff9f62f4c403e9ded172a308884aa6c5145ebc356e49daf3309e6f3896b3357
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/lamby.rb
CHANGED
@@ -2,6 +2,7 @@ require 'lamby/logger'
|
|
2
2
|
require 'rack'
|
3
3
|
require 'base64'
|
4
4
|
require 'lamby/version'
|
5
|
+
require 'lamby/config'
|
5
6
|
require 'lamby/sam_helpers'
|
6
7
|
require 'lamby/rack'
|
7
8
|
require 'lamby/rack_alb'
|
@@ -23,6 +24,10 @@ module Lamby
|
|
23
24
|
Handler.call(app, event, context, options)
|
24
25
|
end
|
25
26
|
|
27
|
+
def config
|
28
|
+
Lamby::Config.config
|
29
|
+
end
|
30
|
+
|
26
31
|
autoload :SsmParameterStore, 'lamby/ssm_parameter_store'
|
27
32
|
|
28
33
|
end
|
data/lib/lamby/config.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Lamby
|
2
|
+
module Config
|
3
|
+
|
4
|
+
def configure
|
5
|
+
yield(config)
|
6
|
+
config
|
7
|
+
end
|
8
|
+
|
9
|
+
def reconfigure
|
10
|
+
config.reconfigure { |c| yield(c) if block_given? }
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
@config ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
extend self
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Configuration
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
initialize_defaults
|
25
|
+
end
|
26
|
+
|
27
|
+
def reconfigure
|
28
|
+
instance_variables.each { |var| instance_variable_set var, nil }
|
29
|
+
initialize_defaults
|
30
|
+
yield(self) if block_given?
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize_defaults
|
35
|
+
@event_bridge_handler = lambda { |event, context| puts(event) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def event_bridge_handler
|
39
|
+
@event_bridge_handler
|
40
|
+
end
|
41
|
+
|
42
|
+
def event_bridge_handler=(func)
|
43
|
+
@event_bridge_handler = func
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/lamby/handler.rb
CHANGED
@@ -47,7 +47,7 @@ module Lamby
|
|
47
47
|
def call
|
48
48
|
return self if @called
|
49
49
|
@status, @headers, @body = call_app
|
50
|
-
set_cookies
|
50
|
+
set_cookies if rack?
|
51
51
|
@called = true
|
52
52
|
self
|
53
53
|
end
|
@@ -78,14 +78,19 @@ module Lamby
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def rack_response
|
81
|
-
rack.response(self)
|
81
|
+
rack? ? rack.response(self) : {}
|
82
82
|
end
|
83
83
|
|
84
84
|
def call_app
|
85
85
|
if Debug.on?(@event)
|
86
86
|
Debug.call @event, @context, rack.env
|
87
|
-
|
87
|
+
elsif rack?
|
88
88
|
@app.call rack.env
|
89
|
+
elsif event_bridge?
|
90
|
+
Lamby.config.event_bridge_handler.call @event, @context
|
91
|
+
[200, {}, StringIO.new('')]
|
92
|
+
else
|
93
|
+
[404, {}, StringIO.new('')]
|
89
94
|
end
|
90
95
|
end
|
91
96
|
|
@@ -93,5 +98,14 @@ module Lamby
|
|
93
98
|
content_encoding_header = hdrs['Content-Encoding'] || ''
|
94
99
|
content_encoding_header.split(', ').any? { |h| ['br', 'gzip'].include?(h) }
|
95
100
|
end
|
101
|
+
|
102
|
+
def rack?
|
103
|
+
@event.key?('httpMethod') || @event.dig('requestContext', 'http')
|
104
|
+
end
|
105
|
+
|
106
|
+
def event_bridge?
|
107
|
+
Lamby.config.event_bridge_handler &&
|
108
|
+
@event.key?('source') && @event.key?('detail') && @event.key?('detail-type')
|
109
|
+
end
|
96
110
|
end
|
97
111
|
end
|
data/lib/lamby/railtie.rb
CHANGED
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.7.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: 2021-04-
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lamby.gemspec
|
152
152
|
- lib/lamby.rb
|
153
153
|
- lib/lamby/bootsnap.rb
|
154
|
+
- lib/lamby/config.rb
|
154
155
|
- lib/lamby/debug.rb
|
155
156
|
- lib/lamby/handler.rb
|
156
157
|
- lib/lamby/logger.rb
|