shark-on-lambda 1.0.0.rc3 → 1.0.0.rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57eec1d01b2f0b45cbc69cc1a9864d72fe763768864a248ce433018c9516b785
4
- data.tar.gz: dc538a1815cecb6dfcb60fdf5405da99a80779deaff4541720ab8aaa13550603
3
+ metadata.gz: f6a831332c510a5977edd5ca1db24a68a9cf7cc323433fb807f5b65a707df0e7
4
+ data.tar.gz: 9beabc2ae1d3d81d9a6b10d80b69668629d902726c535dc3aec403db4ac38c36
5
5
  SHA512:
6
- metadata.gz: 34f5bca1123bc3538e0dfdc4f8a8d4386cb6e112afcd9d9b76d3b09da2b5260ab003a0eaf9c35aee6d17fe4e7a709facdde2be5ac68e9c7df8e2469a0fed8f48
7
- data.tar.gz: fe358c47d3219b942c526bd1837b52f8a23794eced69e6d56419fb4e610335d9fcb7a435cf8b007365b3c675e9ffb8142faaf3d06c3fdc9d4d753213221c35ee
6
+ metadata.gz: b607fdff10e8ff558fb85e3d92bc9697e783aaf2f856822fe84591101f974d89af3cd9a11c41640409c5f0590fb9ef0bf9b0c86e68029112388cd0a110283a08
7
+ data.tar.gz: 4ea5be6f0d30ce7b6f4a05632a9b9c1c96ce18673cb52be4907cdf726fb56982052a06f16874eeb772947ad387b2472d3079e585087146aee7865035ef6a42f7
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SharkOnLambda
4
+ module Middleware
5
+ class Honeybadger < Base
6
+ attr_reader :tags
7
+
8
+ def initialize(app, tags: '')
9
+ super(app)
10
+
11
+ @tags = tags
12
+ end
13
+
14
+ private
15
+
16
+ def _call(env)
17
+ @env = env
18
+ app.call(env)
19
+ rescue StandardError => e
20
+ notify(e) unless shark_error?(e)
21
+
22
+ raise e
23
+ end
24
+
25
+ def notify(error)
26
+ ::Honeybadger.notify(
27
+ error,
28
+ tags: tags,
29
+ controller: @env['shark.controller'],
30
+ action: @env['shark.action'],
31
+ parameters: @env['action_dispatch.request.parameters']
32
+ )
33
+ end
34
+
35
+ def shark_error?(error)
36
+ error.is_a?(Errors::Base)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -29,7 +29,6 @@ module SharkOnLambda
29
29
  def rescue_standard_error(error)
30
30
  SharkOnLambda.logger.error(error.message)
31
31
  SharkOnLambda.logger.error(error.backtrace.join("\n"))
32
- Honeybadger.notify(error) if defined?(Honeybadger)
33
32
 
34
33
  error_response(500, {}, error.message)
35
34
  end
@@ -11,7 +11,7 @@ module SharkOnLambda
11
11
  @action = options.fetch(:action)
12
12
 
13
13
  @headers = (options[:headers] || {}).deep_stringify_keys
14
- @headers.transform_keys! { |key| key.downcase }
14
+ @headers.transform_keys!(&:downcase)
15
15
  @params = options[:params]
16
16
 
17
17
  initialize_env
@@ -47,8 +47,7 @@ module SharkOnLambda
47
47
  body = params.to_json
48
48
 
49
49
  env['rack.input'] = StringIO.new(body).set_encoding(Encoding::BINARY)
50
- env['CONTENT_TYPE'] = headers['content-type']
51
- env['CONTENT_LENGTH'] = body.bytesize.to_s
50
+ set_content_type_and_content_length
52
51
  end
53
52
 
54
53
  def initialize_env
@@ -60,6 +59,11 @@ module SharkOnLambda
60
59
  'shark.action' => action
61
60
  )
62
61
  end
62
+
63
+ def set_content_type_and_content_length
64
+ env['CONTENT_TYPE'] = headers['content-type']
65
+ env['CONTENT_LENGTH'] = env['rack.input'].length.to_s
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SharkOnLambda
4
- VERSION = '1.0.0.rc3'
4
+ VERSION = '1.0.0.rc4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shark-on-lambda
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huy Dinh
@@ -260,7 +260,6 @@ files:
260
260
  - bin/console
261
261
  - bin/setup
262
262
  - changelog.md
263
- - gems.locked
264
263
  - gems.rb
265
264
  - lib/shark-on-lambda.rb
266
265
  - lib/shark_on_lambda.rb
@@ -279,6 +278,7 @@ files:
279
278
  - lib/shark_on_lambda/jsonapi_parameters.rb
280
279
  - lib/shark_on_lambda/jsonapi_renderer.rb
281
280
  - lib/shark_on_lambda/middleware/base.rb
281
+ - lib/shark_on_lambda/middleware/honeybadger.rb
282
282
  - lib/shark_on_lambda/middleware/jsonapi_rescuer.rb
283
283
  - lib/shark_on_lambda/middleware/lambda_logger.rb
284
284
  - lib/shark_on_lambda/middleware/rescuer.rb
data/gems.locked DELETED
@@ -1,142 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- shark-on-lambda (1.0.0.rc3)
5
- actionpack
6
- activesupport
7
- jsonapi-rb
8
- rack (>= 2.0.8, < 3)
9
- zeitwerk (~> 2.2)
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- actionpack (6.0.0)
15
- actionview (= 6.0.0)
16
- activesupport (= 6.0.0)
17
- rack (~> 2.0)
18
- rack-test (>= 0.6.3)
19
- rails-dom-testing (~> 2.0)
20
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
21
- actionview (6.0.0)
22
- activesupport (= 6.0.0)
23
- builder (~> 3.1)
24
- erubi (~> 1.4)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
27
- activemodel (6.0.0)
28
- activesupport (= 6.0.0)
29
- activesupport (6.0.0)
30
- concurrent-ruby (~> 1.0, >= 1.0.2)
31
- i18n (>= 0.7, < 2)
32
- minitest (~> 5.1)
33
- tzinfo (~> 1.1)
34
- zeitwerk (~> 2.1, >= 2.1.8)
35
- ast (2.4.0)
36
- builder (3.2.4)
37
- byebug (11.0.1)
38
- coderay (1.1.2)
39
- colorize (0.8.1)
40
- concurrent-ruby (1.1.5)
41
- crass (1.0.6)
42
- diff-lcs (1.3)
43
- docile (1.3.2)
44
- erubi (1.9.0)
45
- factory_bot (5.1.1)
46
- activesupport (>= 4.2.0)
47
- fasterer (0.8.2)
48
- colorize (~> 0.7)
49
- ruby_parser (>= 3.14.1)
50
- i18n (1.7.0)
51
- concurrent-ruby (~> 1.0)
52
- jaro_winkler (1.5.4)
53
- json (2.2.0)
54
- jsonapi-deserializable (0.2.0)
55
- jsonapi-rb (0.5.0)
56
- jsonapi-deserializable (~> 0.2.0)
57
- jsonapi-serializable (~> 0.3.0)
58
- jsonapi-renderer (0.2.2)
59
- jsonapi-serializable (0.3.1)
60
- jsonapi-renderer (~> 0.2.0)
61
- loofah (2.4.0)
62
- crass (~> 1.0.2)
63
- nokogiri (>= 1.5.9)
64
- method_source (0.9.2)
65
- mini_portile2 (2.4.0)
66
- minitest (5.13.0)
67
- nokogiri (1.10.8)
68
- mini_portile2 (~> 2.4.0)
69
- parallel (1.18.0)
70
- parser (2.6.5.0)
71
- ast (~> 2.4.0)
72
- pry (0.12.2)
73
- coderay (~> 1.1.0)
74
- method_source (~> 0.9.0)
75
- pry-byebug (3.7.0)
76
- byebug (~> 11.0)
77
- pry (~> 0.10)
78
- rack (2.2.2)
79
- rack-test (1.1.0)
80
- rack (>= 1.0, < 3)
81
- rails-dom-testing (2.0.3)
82
- activesupport (>= 4.2.0)
83
- nokogiri (>= 1.6)
84
- rails-html-sanitizer (1.3.0)
85
- loofah (~> 2.3)
86
- rainbow (3.0.0)
87
- rake (13.0.0)
88
- rspec (3.9.0)
89
- rspec-core (~> 3.9.0)
90
- rspec-expectations (~> 3.9.0)
91
- rspec-mocks (~> 3.9.0)
92
- rspec-core (3.9.0)
93
- rspec-support (~> 3.9.0)
94
- rspec-expectations (3.9.0)
95
- diff-lcs (>= 1.2.0, < 2.0)
96
- rspec-support (~> 3.9.0)
97
- rspec-mocks (3.9.0)
98
- diff-lcs (>= 1.2.0, < 2.0)
99
- rspec-support (~> 3.9.0)
100
- rspec-support (3.9.0)
101
- rubocop (0.76.0)
102
- jaro_winkler (~> 1.5.1)
103
- parallel (~> 1.10)
104
- parser (>= 2.6)
105
- rainbow (>= 2.2.2, < 4.0)
106
- ruby-progressbar (~> 1.7)
107
- unicode-display_width (>= 1.4.0, < 1.7)
108
- ruby-progressbar (1.10.1)
109
- ruby_parser (3.14.2)
110
- sexp_processor (~> 4.9)
111
- sexp_processor (4.14.1)
112
- simplecov (0.17.1)
113
- docile (~> 1.1)
114
- json (>= 1.8, < 3)
115
- simplecov-html (~> 0.10.0)
116
- simplecov-html (0.10.2)
117
- thread_safe (0.3.6)
118
- tzinfo (1.2.5)
119
- thread_safe (~> 0.1)
120
- unicode-display_width (1.6.0)
121
- yard (0.9.20)
122
- zeitwerk (2.2.1)
123
-
124
- PLATFORMS
125
- ruby
126
-
127
- DEPENDENCIES
128
- activemodel
129
- bundler
130
- factory_bot
131
- fasterer
132
- pry
133
- pry-byebug
134
- rake
135
- rspec
136
- rubocop
137
- shark-on-lambda!
138
- simplecov
139
- yard
140
-
141
- BUNDLED WITH
142
- 2.1.4