my_api_client 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +39 -37
- data/README.jp.md +17 -0
- data/README.md +15 -0
- data/example/api_clients/my_errors.rb +9 -0
- data/example/api_clients/my_header_api_client.rb +38 -0
- data/lib/my_api_client/error_handling/generator.rb +16 -3
- data/lib/my_api_client/version.rb +1 -1
- data/my_api/Gemfile +2 -2
- data/my_api/Gemfile.lock +58 -58
- data/my_api/app/controllers/header_controller.rb +12 -0
- data/my_api/config/routes.rb +1 -0
- data/my_api/spec/controllers/error_controller_spec.rb +1 -1
- data/my_api/spec/controllers/header_controller_spec.rb +33 -0
- data/my_api/spec/controllers/pagination_controller_spec.rb +1 -1
- data/my_api/spec/controllers/rest_controller_spec.rb +1 -1
- data/my_api/spec/controllers/status_controller_spec.rb +1 -1
- data/rails_app/rails_5.2/Gemfile.lock +4 -4
- data/rails_app/rails_6.0/Gemfile.lock +4 -4
- data/rails_app/rails_6.1/Gemfile.lock +3 -3
- data/rails_app/rails_7.0/Gemfile.lock +4 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 625b09ebe3b913ebf52c369554945368280eedb5610c6c9af64d0f0115ff4414
|
4
|
+
data.tar.gz: e2bd5807d57814f29ffed4cbc4a708f21925ab3546734d00e10296073a987240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4b479a449d2c7d06953b9daf954c37d4861fa02f42af93275774668c690792292784ca69cdc9fae68d3ee347bc09e595ac15837904ada9635526448afd146d
|
7
|
+
data.tar.gz: f0e4b6b765fb5e14080531ea09d51226cea45fa6b6ad81077b39ffa41ade1656dc4cf2818bbbded6955ed91117df7e2093ec0f89969990734a8b6d6baaccf3f0
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-
|
3
|
+
# on 2022-10-23 23:31:24 UTC using RuboCop version 1.33.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## v0.24.0 (Nov 07, 2022)
|
4
|
+
|
5
|
+
### Feature
|
6
|
+
|
7
|
+
- [#792](https://github.com/ryz310/my_api_client/pull/792) Support response header error handling ([@okumud](https://github.com/okumud))
|
8
|
+
|
9
|
+
### Rubocop Challenge
|
10
|
+
|
11
|
+
- [#757](https://github.com/ryz310/my_api_client/pull/757) RSpec/Rails/HaveHttpStatus-20220712233101 ([@ryz310](https://github.com/ryz310))
|
12
|
+
- [#777](https://github.com/ryz310/my_api_client/pull/777) RSpec/ClassCheck-20220912233101 ([@ryz310](https://github.com/ryz310))
|
13
|
+
- [#790](https://github.com/ryz310/my_api_client/pull/790) RSpec/Rails/InferredSpecType-20221023233100 ([@ryz310](https://github.com/ryz310))
|
14
|
+
|
15
|
+
### Dependabot
|
16
|
+
|
17
|
+
- [#758](https://github.com/ryz310/my_api_client/pull/758) ryz310/dependabot/bundler/rubocop-performance-1.14.3 ([@ryz310](https://github.com/ryz310))
|
18
|
+
- [#772](https://github.com/ryz310/my_api_client/pull/772) Bump pry-byebug from 3.10.0 to 3.10.1 ([@ryz310](https://github.com/ryz310))
|
19
|
+
- [#773](https://github.com/ryz310/my_api_client/pull/773) Bump webmock from 3.17.1 to 3.18.1 ([@ryz310](https://github.com/ryz310))
|
20
|
+
- [#775](https://github.com/ryz310/my_api_client/pull/775) Bump activesupport from 7.0.3.1 to 7.0.4 ([@ryz310](https://github.com/ryz310))
|
21
|
+
- [#778](https://github.com/ryz310/my_api_client/pull/778) Bump rspec_junit_formatter from 0.5.1 to 0.6.0 ([@ryz310](https://github.com/ryz310))
|
22
|
+
- [#780](https://github.com/ryz310/my_api_client/pull/780) Bump faraday from 2.5.2 to 2.6.0 ([@ryz310](https://github.com/ryz310))
|
23
|
+
- [#791](https://github.com/ryz310/my_api_client/pull/791) Bump rspec from 3.11.0 to 3.12.0 ([@ryz310](https://github.com/ryz310))
|
24
|
+
|
25
|
+
### Misc
|
26
|
+
|
27
|
+
- [#784](https://github.com/ryz310/my_api_client/pull/784) Pin the version of the jets gem ([@ryz310](https://github.com/ryz310))
|
28
|
+
|
3
29
|
## v0.23.0 (Jun 08, 2022)
|
4
30
|
|
5
31
|
### Feature
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
my_api_client (0.
|
4
|
+
my_api_client (0.24.0)
|
5
5
|
activesupport (>= 5.2.0)
|
6
6
|
faraday (>= 0.17.1)
|
7
7
|
jsonpath
|
@@ -10,13 +10,13 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (7.0.
|
13
|
+
activesupport (7.0.4)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 1.6, < 2)
|
16
16
|
minitest (>= 5.1)
|
17
17
|
tzinfo (~> 2.0)
|
18
|
-
addressable (2.8.
|
19
|
-
public_suffix (>= 2.0.2, <
|
18
|
+
addressable (2.8.1)
|
19
|
+
public_suffix (>= 2.0.2, < 6.0)
|
20
20
|
ast (2.4.2)
|
21
21
|
bugsnag (6.24.2)
|
22
22
|
concurrent-ruby (~> 1.0)
|
@@ -27,63 +27,65 @@ GEM
|
|
27
27
|
rexml
|
28
28
|
diff-lcs (1.5.0)
|
29
29
|
docile (1.4.0)
|
30
|
-
faraday (2.
|
31
|
-
faraday-net_http (
|
30
|
+
faraday (2.6.0)
|
31
|
+
faraday-net_http (>= 2.0, < 3.1)
|
32
32
|
ruby2_keywords (>= 0.0.4)
|
33
|
-
faraday-net_http (
|
33
|
+
faraday-net_http (3.0.1)
|
34
34
|
hashdiff (1.0.1)
|
35
|
-
i18n (1.
|
35
|
+
i18n (1.12.0)
|
36
36
|
concurrent-ruby (~> 1.0)
|
37
|
+
json (2.6.2)
|
37
38
|
jsonpath (1.1.2)
|
38
39
|
multi_json
|
39
40
|
method_source (1.0.0)
|
40
|
-
minitest (5.
|
41
|
+
minitest (5.16.3)
|
41
42
|
multi_json (1.15.0)
|
42
43
|
parallel (1.22.1)
|
43
|
-
parser (3.1.2.
|
44
|
+
parser (3.1.2.1)
|
44
45
|
ast (~> 2.4.1)
|
45
|
-
pry (0.
|
46
|
+
pry (0.14.1)
|
46
47
|
coderay (~> 1.1)
|
47
48
|
method_source (~> 1.0)
|
48
|
-
pry-byebug (3.
|
49
|
+
pry-byebug (3.10.1)
|
49
50
|
byebug (~> 11.0)
|
50
|
-
pry (
|
51
|
-
public_suffix (
|
51
|
+
pry (>= 0.13, < 0.15)
|
52
|
+
public_suffix (5.0.0)
|
52
53
|
rainbow (3.1.1)
|
53
54
|
rake (13.0.6)
|
54
|
-
regexp_parser (2.
|
55
|
+
regexp_parser (2.6.0)
|
55
56
|
rexml (3.2.5)
|
56
|
-
rspec (3.
|
57
|
-
rspec-core (~> 3.
|
58
|
-
rspec-expectations (~> 3.
|
59
|
-
rspec-mocks (~> 3.
|
60
|
-
rspec-core (3.
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-expectations (3.
|
57
|
+
rspec (3.12.0)
|
58
|
+
rspec-core (~> 3.12.0)
|
59
|
+
rspec-expectations (~> 3.12.0)
|
60
|
+
rspec-mocks (~> 3.12.0)
|
61
|
+
rspec-core (3.12.0)
|
62
|
+
rspec-support (~> 3.12.0)
|
63
|
+
rspec-expectations (3.12.0)
|
63
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-mocks (3.
|
65
|
+
rspec-support (~> 3.12.0)
|
66
|
+
rspec-mocks (3.12.0)
|
66
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-support (3.
|
69
|
-
rspec_junit_formatter (0.
|
68
|
+
rspec-support (~> 3.12.0)
|
69
|
+
rspec-support (3.12.0)
|
70
|
+
rspec_junit_formatter (0.6.0)
|
70
71
|
rspec-core (>= 2, < 4, != 2.12.0)
|
71
|
-
rubocop (1.
|
72
|
+
rubocop (1.38.0)
|
73
|
+
json (~> 2.3)
|
72
74
|
parallel (~> 1.10)
|
73
|
-
parser (>= 3.1.
|
75
|
+
parser (>= 3.1.2.1)
|
74
76
|
rainbow (>= 2.2.2, < 4.0)
|
75
77
|
regexp_parser (>= 1.8, < 3.0)
|
76
78
|
rexml (>= 3.2.5, < 4.0)
|
77
|
-
rubocop-ast (>= 1.
|
79
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
78
80
|
ruby-progressbar (~> 1.7)
|
79
81
|
unicode-display_width (>= 1.4.0, < 3.0)
|
80
|
-
rubocop-ast (1.
|
82
|
+
rubocop-ast (1.23.0)
|
81
83
|
parser (>= 3.1.1.0)
|
82
|
-
rubocop-performance (1.
|
84
|
+
rubocop-performance (1.15.0)
|
83
85
|
rubocop (>= 1.7.0, < 2.0)
|
84
86
|
rubocop-ast (>= 0.4.0)
|
85
|
-
rubocop-rspec (2.
|
86
|
-
rubocop (~> 1.
|
87
|
+
rubocop-rspec (2.15.0)
|
88
|
+
rubocop (~> 1.33)
|
87
89
|
ruby-progressbar (1.11.0)
|
88
90
|
ruby2_keywords (0.0.5)
|
89
91
|
sawyer (0.9.2)
|
@@ -95,10 +97,10 @@ GEM
|
|
95
97
|
simplecov_json_formatter (~> 0.1)
|
96
98
|
simplecov-html (0.12.3)
|
97
99
|
simplecov_json_formatter (0.1.4)
|
98
|
-
tzinfo (2.0.
|
100
|
+
tzinfo (2.0.5)
|
99
101
|
concurrent-ruby (~> 1.0)
|
100
|
-
unicode-display_width (2.
|
101
|
-
webmock (3.
|
102
|
+
unicode-display_width (2.3.0)
|
103
|
+
webmock (3.18.1)
|
102
104
|
addressable (>= 2.8.0)
|
103
105
|
crack (>= 0.3.2)
|
104
106
|
hashdiff (>= 0.4.0, < 2.0.0)
|
data/README.jp.md
CHANGED
@@ -221,6 +221,23 @@ error_handling json: { '$.errors.code': 10..19 }, with: :my_error_handling
|
|
221
221
|
}
|
222
222
|
```
|
223
223
|
|
224
|
+
`headers` には `Hash` の Key に レスポンスのヘッダーキーを指定して、 Value とマッチするかどうかでエラーハンドリングできます。Value には `String` `Regexp` が指定可能です。
|
225
|
+
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
error_handling headers: { 'www-authenticate': /invalid token/ }, with: :my_error_handling
|
229
|
+
```
|
230
|
+
|
231
|
+
上記の場合であれば、以下のような レスポンスヘッダー にマッチします。
|
232
|
+
|
233
|
+
```text
|
234
|
+
cache-control: no-cache, no-store, max-age=0, must-revalidate
|
235
|
+
content-type: application/json
|
236
|
+
www-authenticate: Bearer error="invalid_token", error_description="invalid token"
|
237
|
+
content-length: 104
|
238
|
+
```
|
239
|
+
|
240
|
+
|
224
241
|
`with` にはインスタンスメソッド名を指定することで、エラーを検出した際、例外を発生させる前に任意のメソッドを実行させることができます。メソッドに渡される引数は `block` 定義の場合と同じく `params` と `logger` です。なお、 `block` と `with` は同時には利用できません。
|
225
242
|
|
226
243
|
```ruby
|
data/README.md
CHANGED
@@ -223,6 +223,21 @@ In the above case, it matches JSON as below:
|
|
223
223
|
}
|
224
224
|
```
|
225
225
|
|
226
|
+
For `headers`, specify response header for the Key of `Hash`, get an arbitrary value from the response header, and check whether it matches value. You can handle errors. You can specify `String` and `Regexp` for value.
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
error_handling headers: { 'www-authenticate': /invalid token/ }, with: :my_error_handling
|
230
|
+
```
|
231
|
+
|
232
|
+
In the above case, it matches response header as below:
|
233
|
+
|
234
|
+
```text
|
235
|
+
cache-control: no-cache, no-store, max-age=0, must-revalidate
|
236
|
+
content-type: application/json
|
237
|
+
www-authenticate: Bearer error="invalid_token", error_description="invalid token"
|
238
|
+
content-length: 104
|
239
|
+
```
|
240
|
+
|
226
241
|
By specifying the instance method name in `with`, when an error is detected, any method can be executed before raising an exception. The arguments passed to the method are `params` and `logger` as in the `block` definition. Note that `block` and` with` cannot be used at the same time.
|
227
242
|
|
228
243
|
```ruby
|
@@ -24,4 +24,13 @@ module MyErrors
|
|
24
24
|
|
25
25
|
# Error code: other
|
26
26
|
class ErrorCodeOther < MyApiClient::ClientError; end
|
27
|
+
|
28
|
+
# Header: X-First-Header has invalid
|
29
|
+
class FirstHeaderIsInvalid < MyApiClient::ClientError; end
|
30
|
+
|
31
|
+
# Header: X-First-Header has nothing and status is 404
|
32
|
+
class FirstHeaderHasNothingAndNotFound < MyApiClient::ClientError; end
|
33
|
+
|
34
|
+
# Header: X-First-Header has unknown and X-Second-Header has error
|
35
|
+
class MultipleHeaderIsInvalid < MyApiClient::ClientError; end
|
27
36
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'application_api_client'
|
4
|
+
|
5
|
+
# An usage example of the `my_api_client`.
|
6
|
+
# See also: my_api/app/controllers/header_controller.rb
|
7
|
+
class MyHeaderApiClient < ApplicationApiClient
|
8
|
+
error_handling headers: { 'X-First-Header': /invalid/ },
|
9
|
+
raise: MyErrors::FirstHeaderIsInvalid
|
10
|
+
|
11
|
+
error_handling headers: {
|
12
|
+
'X-First-Header': /unknown/,
|
13
|
+
'X-Second-Header': /error/,
|
14
|
+
},
|
15
|
+
raise: MyErrors::MultipleHeaderIsInvalid
|
16
|
+
|
17
|
+
error_handling headers: { 'X-First-Header': /nothing/ },
|
18
|
+
status_code: 404,
|
19
|
+
raise: MyErrors::FirstHeaderHasNothingAndNotFound
|
20
|
+
|
21
|
+
# GET header
|
22
|
+
#
|
23
|
+
# @param first_header [String] X-First-Header
|
24
|
+
# @param second_header [String] X-Second-Header
|
25
|
+
# @return [Sawyer::Resource]
|
26
|
+
def get_header(first_header:, second_header:)
|
27
|
+
get 'header', headers: headers, query: {
|
28
|
+
'X-First-Header': first_header,
|
29
|
+
'X-Second-Header': second_header,
|
30
|
+
}.compact
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def headers
|
36
|
+
{ 'Content-Type': 'application/json;charset=UTF-8' }
|
37
|
+
end
|
38
|
+
end
|
@@ -4,7 +4,7 @@ module MyApiClient
|
|
4
4
|
module ErrorHandling
|
5
5
|
# Generates an error handler proc (or symbol)
|
6
6
|
class Generator < ServiceAbstract
|
7
|
-
ARGUMENTS = %i[instance response status_code json with raise block].freeze
|
7
|
+
ARGUMENTS = %i[instance response status_code headers json with raise block].freeze
|
8
8
|
|
9
9
|
# @param options [Hash]
|
10
10
|
# Options for this generator
|
@@ -14,6 +14,8 @@ module MyApiClient
|
|
14
14
|
# The target of verifying
|
15
15
|
# @option status_code [String, Range, Integer, Regexp]
|
16
16
|
# Verifies response HTTP status code and raises error if matched
|
17
|
+
# @option headers [String, Regexp]
|
18
|
+
# Verifies response HTTP header and raises error if matched
|
17
19
|
# @option json [Hash, Symbol]
|
18
20
|
# Verifies response body as JSON and raises error if matched.
|
19
21
|
# If specified `:forbid_nil`, it forbid `nil` on response_body.
|
@@ -36,7 +38,8 @@ module MyApiClient
|
|
36
38
|
|
37
39
|
def call
|
38
40
|
return unless match?(_status_code, _response.status)
|
39
|
-
return unless
|
41
|
+
return unless match_headers?(_headers, _response.headers)
|
42
|
+
return unless match_body?(_json, _response.body)
|
40
43
|
|
41
44
|
generate_error_handler
|
42
45
|
end
|
@@ -102,7 +105,17 @@ module MyApiClient
|
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
105
|
-
def
|
108
|
+
def match_headers?(headers, response_headers)
|
109
|
+
return true if headers.nil?
|
110
|
+
return false if response_headers.blank?
|
111
|
+
|
112
|
+
headers.all? do |header_key, operator|
|
113
|
+
target = response_headers[header_key]
|
114
|
+
match?(operator, target)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def match_body?(json, response_body)
|
106
119
|
return true if json.nil?
|
107
120
|
return response_body.nil? if json == :forbid_nil
|
108
121
|
return false if response_body.blank?
|
data/my_api/Gemfile
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem 'jets'
|
5
|
+
gem 'jets', '~> 3.1.5'
|
6
6
|
|
7
7
|
gem 'dynomite'
|
8
8
|
|
9
9
|
# See: https://github.com/boltops-tools/jets/issues/523
|
10
|
-
gem 'nokogiri', '~> 1.13.
|
10
|
+
gem 'nokogiri', '~> 1.13.8'
|
11
11
|
|
12
12
|
# development and test groups are not bundled as part of the deployment
|
13
13
|
group :development, :test do
|
data/my_api/Gemfile.lock
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (6.1.
|
5
|
-
actionpack (= 6.1.
|
6
|
-
actionview (= 6.1.
|
7
|
-
activejob (= 6.1.
|
8
|
-
activesupport (= 6.1.
|
4
|
+
actionmailer (6.1.6.1)
|
5
|
+
actionpack (= 6.1.6.1)
|
6
|
+
actionview (= 6.1.6.1)
|
7
|
+
activejob (= 6.1.6.1)
|
8
|
+
activesupport (= 6.1.6.1)
|
9
9
|
mail (~> 2.5, >= 2.5.4)
|
10
10
|
rails-dom-testing (~> 2.0)
|
11
|
-
actionpack (6.1.
|
12
|
-
actionview (= 6.1.
|
13
|
-
activesupport (= 6.1.
|
11
|
+
actionpack (6.1.6.1)
|
12
|
+
actionview (= 6.1.6.1)
|
13
|
+
activesupport (= 6.1.6.1)
|
14
14
|
rack (~> 2.0, >= 2.0.9)
|
15
15
|
rack-test (>= 0.6.3)
|
16
16
|
rails-dom-testing (~> 2.0)
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
-
actionview (6.1.
|
19
|
-
activesupport (= 6.1.
|
18
|
+
actionview (6.1.6.1)
|
19
|
+
activesupport (= 6.1.6.1)
|
20
20
|
builder (~> 3.1)
|
21
21
|
erubi (~> 1.4)
|
22
22
|
rails-dom-testing (~> 2.0)
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
-
activejob (6.1.
|
25
|
-
activesupport (= 6.1.
|
24
|
+
activejob (6.1.6.1)
|
25
|
+
activesupport (= 6.1.6.1)
|
26
26
|
globalid (>= 0.3.6)
|
27
|
-
activemodel (6.1.
|
28
|
-
activesupport (= 6.1.
|
29
|
-
activerecord (6.1.
|
30
|
-
activemodel (= 6.1.
|
31
|
-
activesupport (= 6.1.
|
32
|
-
activesupport (6.1.
|
27
|
+
activemodel (6.1.6.1)
|
28
|
+
activesupport (= 6.1.6.1)
|
29
|
+
activerecord (6.1.6.1)
|
30
|
+
activemodel (= 6.1.6.1)
|
31
|
+
activesupport (= 6.1.6.1)
|
32
|
+
activesupport (6.1.6.1)
|
33
33
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
34
34
|
i18n (>= 1.6, < 2)
|
35
35
|
minitest (>= 5.1)
|
@@ -46,47 +46,47 @@ GEM
|
|
46
46
|
rainbow
|
47
47
|
thor
|
48
48
|
zeitwerk
|
49
|
-
aws-partitions (1.
|
50
|
-
aws-sdk-apigateway (1.
|
49
|
+
aws-partitions (1.616.0)
|
50
|
+
aws-sdk-apigateway (1.78.0)
|
51
51
|
aws-sdk-core (~> 3, >= 3.127.0)
|
52
52
|
aws-sigv4 (~> 1.1)
|
53
|
-
aws-sdk-cloudformation (1.
|
53
|
+
aws-sdk-cloudformation (1.70.0)
|
54
54
|
aws-sdk-core (~> 3, >= 3.127.0)
|
55
55
|
aws-sigv4 (~> 1.1)
|
56
|
-
aws-sdk-cloudwatchlogs (1.
|
56
|
+
aws-sdk-cloudwatchlogs (1.53.0)
|
57
57
|
aws-sdk-core (~> 3, >= 3.127.0)
|
58
58
|
aws-sigv4 (~> 1.1)
|
59
|
-
aws-sdk-core (3.
|
59
|
+
aws-sdk-core (3.132.0)
|
60
60
|
aws-eventstream (~> 1, >= 1.0.2)
|
61
61
|
aws-partitions (~> 1, >= 1.525.0)
|
62
62
|
aws-sigv4 (~> 1.1)
|
63
|
-
jmespath (~> 1.
|
64
|
-
aws-sdk-dynamodb (1.
|
63
|
+
jmespath (~> 1, >= 1.6.1)
|
64
|
+
aws-sdk-dynamodb (1.75.0)
|
65
65
|
aws-sdk-core (~> 3, >= 3.127.0)
|
66
66
|
aws-sigv4 (~> 1.1)
|
67
67
|
aws-sdk-kinesis (1.41.0)
|
68
68
|
aws-sdk-core (~> 3, >= 3.127.0)
|
69
69
|
aws-sigv4 (~> 1.1)
|
70
|
-
aws-sdk-kms (1.
|
70
|
+
aws-sdk-kms (1.58.0)
|
71
71
|
aws-sdk-core (~> 3, >= 3.127.0)
|
72
72
|
aws-sigv4 (~> 1.1)
|
73
|
-
aws-sdk-lambda (1.
|
73
|
+
aws-sdk-lambda (1.84.0)
|
74
74
|
aws-sdk-core (~> 3, >= 3.127.0)
|
75
75
|
aws-sigv4 (~> 1.1)
|
76
|
-
aws-sdk-s3 (1.
|
76
|
+
aws-sdk-s3 (1.114.0)
|
77
77
|
aws-sdk-core (~> 3, >= 3.127.0)
|
78
78
|
aws-sdk-kms (~> 1)
|
79
79
|
aws-sigv4 (~> 1.4)
|
80
80
|
aws-sdk-sns (1.53.0)
|
81
81
|
aws-sdk-core (~> 3, >= 3.127.0)
|
82
82
|
aws-sigv4 (~> 1.1)
|
83
|
-
aws-sdk-sqs (1.51.
|
83
|
+
aws-sdk-sqs (1.51.1)
|
84
84
|
aws-sdk-core (~> 3, >= 3.127.0)
|
85
85
|
aws-sigv4 (~> 1.1)
|
86
|
-
aws-sdk-ssm (1.
|
86
|
+
aws-sdk-ssm (1.138.0)
|
87
87
|
aws-sdk-core (~> 3, >= 3.127.0)
|
88
88
|
aws-sigv4 (~> 1.1)
|
89
|
-
aws-sigv4 (1.5.
|
89
|
+
aws-sigv4 (1.5.1)
|
90
90
|
aws-eventstream (~> 1, >= 1.0.2)
|
91
91
|
aws_config (0.1.0)
|
92
92
|
builder (3.2.4)
|
@@ -110,19 +110,19 @@ GEM
|
|
110
110
|
concurrent-ruby (1.1.10)
|
111
111
|
crass (1.0.6)
|
112
112
|
diff-lcs (1.5.0)
|
113
|
-
dotenv (2.
|
114
|
-
dynomite (1.2.
|
113
|
+
dotenv (2.8.1)
|
114
|
+
dynomite (1.2.7)
|
115
115
|
activesupport
|
116
116
|
aws-sdk-dynamodb
|
117
117
|
rainbow
|
118
|
-
erubi (1.
|
118
|
+
erubi (1.11.0)
|
119
119
|
gems (1.2.0)
|
120
120
|
globalid (1.0.0)
|
121
121
|
activesupport (>= 5.0)
|
122
122
|
hashie (5.0.0)
|
123
|
-
i18n (1.
|
123
|
+
i18n (1.12.0)
|
124
124
|
concurrent-ruby (~> 1.0)
|
125
|
-
jets (3.1.
|
125
|
+
jets (3.1.5)
|
126
126
|
actionmailer (~> 6.1.0)
|
127
127
|
actionpack (~> 6.1.0)
|
128
128
|
actionview (~> 6.1.0)
|
@@ -140,7 +140,7 @@ GEM
|
|
140
140
|
aws-sdk-sqs
|
141
141
|
aws-sdk-ssm
|
142
142
|
cfn-status
|
143
|
-
cfn_camelizer (
|
143
|
+
cfn_camelizer (>= 0.4.9)
|
144
144
|
cfn_response
|
145
145
|
dotenv
|
146
146
|
gems
|
@@ -153,19 +153,19 @@ GEM
|
|
153
153
|
railties (~> 6.1.0)
|
154
154
|
rainbow
|
155
155
|
recursive-open-struct
|
156
|
-
serverlessgems (
|
156
|
+
serverlessgems (>= 0.2.0)
|
157
157
|
shotgun
|
158
158
|
text-table
|
159
159
|
thor
|
160
|
-
zeitwerk (
|
160
|
+
zeitwerk (>= 2.6.0)
|
161
161
|
jets-html-sanitizer (1.0.4)
|
162
162
|
loofah (~> 2.2, >= 2.2.2)
|
163
163
|
jmespath (1.6.1)
|
164
|
-
kramdown (2.
|
164
|
+
kramdown (2.4.0)
|
165
165
|
rexml
|
166
166
|
launchy (2.5.0)
|
167
167
|
addressable (~> 2.7)
|
168
|
-
loofah (2.
|
168
|
+
loofah (2.18.0)
|
169
169
|
crass (~> 1.0.2)
|
170
170
|
nokogiri (>= 1.5.9)
|
171
171
|
mail (2.7.1)
|
@@ -175,26 +175,26 @@ GEM
|
|
175
175
|
method_source (1.0.0)
|
176
176
|
mini_mime (1.1.2)
|
177
177
|
mini_portile2 (2.8.0)
|
178
|
-
minitest (5.
|
178
|
+
minitest (5.16.2)
|
179
179
|
nio4r (2.5.8)
|
180
|
-
nokogiri (1.13.
|
180
|
+
nokogiri (1.13.8)
|
181
181
|
mini_portile2 (~> 2.8.0)
|
182
182
|
racc (~> 1.4)
|
183
183
|
public_suffix (4.0.7)
|
184
|
-
puma (5.6.
|
184
|
+
puma (5.6.5)
|
185
185
|
nio4r (~> 2.0)
|
186
186
|
racc (1.6.0)
|
187
|
-
rack (2.2.
|
188
|
-
rack-test (
|
189
|
-
rack (>= 1.
|
187
|
+
rack (2.2.4)
|
188
|
+
rack-test (2.0.2)
|
189
|
+
rack (>= 1.3)
|
190
190
|
rails-dom-testing (2.0.3)
|
191
191
|
activesupport (>= 4.2.0)
|
192
192
|
nokogiri (>= 1.6)
|
193
|
-
rails-html-sanitizer (1.4.
|
193
|
+
rails-html-sanitizer (1.4.3)
|
194
194
|
loofah (~> 2.3)
|
195
|
-
railties (6.1.
|
196
|
-
actionpack (= 6.1.
|
197
|
-
activesupport (= 6.1.
|
195
|
+
railties (6.1.6.1)
|
196
|
+
actionpack (= 6.1.6.1)
|
197
|
+
activesupport (= 6.1.6.1)
|
198
198
|
method_source
|
199
199
|
rake (>= 12.2)
|
200
200
|
thor (~> 1.0)
|
@@ -215,10 +215,10 @@ GEM
|
|
215
215
|
rspec-mocks (3.11.0)
|
216
216
|
diff-lcs (>= 1.2.0, < 2.0)
|
217
217
|
rspec-support (~> 3.11.0)
|
218
|
-
rspec-support (3.11.
|
219
|
-
rspec_junit_formatter (0.
|
218
|
+
rspec-support (3.11.1)
|
219
|
+
rspec_junit_formatter (0.6.0)
|
220
220
|
rspec-core (>= 2, < 4, != 2.12.0)
|
221
|
-
serverlessgems (0.
|
221
|
+
serverlessgems (0.2.0)
|
222
222
|
gems
|
223
223
|
memoist
|
224
224
|
zeitwerk
|
@@ -226,11 +226,11 @@ GEM
|
|
226
226
|
rack (>= 1.0)
|
227
227
|
text-table (1.2.4)
|
228
228
|
thor (1.2.1)
|
229
|
-
tzinfo (2.0.
|
229
|
+
tzinfo (2.0.5)
|
230
230
|
concurrent-ruby (~> 1.0)
|
231
231
|
xpath (3.2.0)
|
232
232
|
nokogiri (~> 1.8)
|
233
|
-
zeitwerk (2.
|
233
|
+
zeitwerk (2.6.0)
|
234
234
|
|
235
235
|
PLATFORMS
|
236
236
|
ruby
|
@@ -239,9 +239,9 @@ DEPENDENCIES
|
|
239
239
|
byebug
|
240
240
|
capybara
|
241
241
|
dynomite
|
242
|
-
jets
|
242
|
+
jets (~> 3.1.5)
|
243
243
|
launchy
|
244
|
-
nokogiri (~> 1.13.
|
244
|
+
nokogiri (~> 1.13.8)
|
245
245
|
puma
|
246
246
|
rack
|
247
247
|
rspec
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The header API
|
4
|
+
class HeaderController < ApplicationController
|
5
|
+
# GET header
|
6
|
+
def index
|
7
|
+
params.each do |header_name, header_value|
|
8
|
+
response.set_header(header_name, header_value)
|
9
|
+
end
|
10
|
+
render status: :ok, json: {}
|
11
|
+
end
|
12
|
+
end
|
data/my_api/config/routes.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe HeaderController do
|
4
|
+
describe '#index' do
|
5
|
+
context 'when request header with a header' do
|
6
|
+
let(:headers) { { 'x-header': 'value' } }
|
7
|
+
|
8
|
+
it 'returns 200 OK request with header' do
|
9
|
+
get '/header', query: headers
|
10
|
+
expect(response.status).to eq 200
|
11
|
+
expect(response.body).to eq '{}'
|
12
|
+
expect(response.headers['x-header']).to eq 'value'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when request header with multiple headers' do
|
17
|
+
let(:headers) do
|
18
|
+
{
|
19
|
+
'x-header': 'value1',
|
20
|
+
'x-second-header': 'value2',
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns 200 OK request with header' do
|
25
|
+
get '/header', query: headers
|
26
|
+
expect(response.status).to eq 200
|
27
|
+
expect(response.body).to eq '{}'
|
28
|
+
expect(response.headers['x-header']).to eq 'value1'
|
29
|
+
expect(response.headers['x-second-header']).to eq 'value2'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -81,7 +81,7 @@ GEM
|
|
81
81
|
concurrent-ruby (~> 1.0)
|
82
82
|
jsonpath (1.1.0)
|
83
83
|
multi_json
|
84
|
-
loofah (2.
|
84
|
+
loofah (2.18.0)
|
85
85
|
crass (~> 1.0.2)
|
86
86
|
nokogiri (>= 1.5.9)
|
87
87
|
mail (2.7.1)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
multi_json (1.15.0)
|
96
96
|
multipart-post (2.1.1)
|
97
97
|
nio4r (2.5.7)
|
98
|
-
nokogiri (1.13.
|
98
|
+
nokogiri (1.13.9)
|
99
99
|
mini_portile2 (~> 2.8.0)
|
100
100
|
racc (~> 1.4)
|
101
101
|
public_suffix (4.0.6)
|
@@ -119,7 +119,7 @@ GEM
|
|
119
119
|
rails-dom-testing (2.0.3)
|
120
120
|
activesupport (>= 4.2.0)
|
121
121
|
nokogiri (>= 1.6)
|
122
|
-
rails-html-sanitizer (1.3
|
122
|
+
rails-html-sanitizer (1.4.3)
|
123
123
|
loofah (~> 2.3)
|
124
124
|
railties (5.2.6)
|
125
125
|
actionpack (= 5.2.6)
|
@@ -159,7 +159,7 @@ GEM
|
|
159
159
|
sprockets (>= 3.0.0)
|
160
160
|
thor (1.1.0)
|
161
161
|
thread_safe (0.3.6)
|
162
|
-
tzinfo (1.2.
|
162
|
+
tzinfo (1.2.10)
|
163
163
|
thread_safe (~> 0.1)
|
164
164
|
websocket-driver (0.7.4)
|
165
165
|
websocket-extensions (>= 0.1.0)
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
concurrent-ruby (~> 1.0)
|
86
86
|
jsonpath (1.1.2)
|
87
87
|
multi_json
|
88
|
-
loofah (2.
|
88
|
+
loofah (2.18.0)
|
89
89
|
crass (~> 1.0.2)
|
90
90
|
nokogiri (>= 1.5.9)
|
91
91
|
mail (2.7.1)
|
@@ -98,7 +98,7 @@ GEM
|
|
98
98
|
msgpack (1.4.2)
|
99
99
|
multi_json (1.15.0)
|
100
100
|
nio4r (2.5.8)
|
101
|
-
nokogiri (1.13.
|
101
|
+
nokogiri (1.13.9)
|
102
102
|
mini_portile2 (~> 2.8.0)
|
103
103
|
racc (~> 1.4)
|
104
104
|
psych (3.3.2)
|
@@ -125,7 +125,7 @@ GEM
|
|
125
125
|
rails-dom-testing (2.0.3)
|
126
126
|
activesupport (>= 4.2.0)
|
127
127
|
nokogiri (>= 1.6)
|
128
|
-
rails-html-sanitizer (1.4.
|
128
|
+
rails-html-sanitizer (1.4.3)
|
129
129
|
loofah (~> 2.3)
|
130
130
|
railties (6.0.4.8)
|
131
131
|
actionpack (= 6.0.4.8)
|
@@ -165,7 +165,7 @@ GEM
|
|
165
165
|
sprockets (>= 3.0.0)
|
166
166
|
thor (1.2.1)
|
167
167
|
thread_safe (0.3.6)
|
168
|
-
tzinfo (1.2.
|
168
|
+
tzinfo (1.2.10)
|
169
169
|
thread_safe (~> 0.1)
|
170
170
|
websocket-driver (0.7.5)
|
171
171
|
websocket-extensions (>= 0.1.0)
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
listen (3.3.3)
|
92
92
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
93
93
|
rb-inotify (~> 0.9, >= 0.9.10)
|
94
|
-
loofah (2.
|
94
|
+
loofah (2.18.0)
|
95
95
|
crass (~> 1.0.2)
|
96
96
|
nokogiri (>= 1.5.9)
|
97
97
|
mail (2.7.1)
|
@@ -103,7 +103,7 @@ GEM
|
|
103
103
|
minitest (5.15.0)
|
104
104
|
multi_json (1.15.0)
|
105
105
|
nio4r (2.5.8)
|
106
|
-
nokogiri (1.13.
|
106
|
+
nokogiri (1.13.9)
|
107
107
|
mini_portile2 (~> 2.8.0)
|
108
108
|
racc (~> 1.4)
|
109
109
|
public_suffix (4.0.7)
|
@@ -129,7 +129,7 @@ GEM
|
|
129
129
|
rails-dom-testing (2.0.3)
|
130
130
|
activesupport (>= 4.2.0)
|
131
131
|
nokogiri (>= 1.6)
|
132
|
-
rails-html-sanitizer (1.4.
|
132
|
+
rails-html-sanitizer (1.4.3)
|
133
133
|
loofah (~> 2.3)
|
134
134
|
railties (6.1.5.1)
|
135
135
|
actionpack (= 6.1.5.1)
|
@@ -99,7 +99,7 @@ GEM
|
|
99
99
|
reline (>= 0.3.0)
|
100
100
|
jsonpath (1.1.2)
|
101
101
|
multi_json
|
102
|
-
loofah (2.
|
102
|
+
loofah (2.18.0)
|
103
103
|
crass (~> 1.0.2)
|
104
104
|
nokogiri (>= 1.5.9)
|
105
105
|
mail (2.7.1)
|
@@ -124,9 +124,9 @@ GEM
|
|
124
124
|
net-protocol
|
125
125
|
timeout
|
126
126
|
nio4r (2.5.8)
|
127
|
-
nokogiri (1.13.
|
127
|
+
nokogiri (1.13.9-x86_64-darwin)
|
128
128
|
racc (~> 1.4)
|
129
|
-
nokogiri (1.13.
|
129
|
+
nokogiri (1.13.9-x86_64-linux)
|
130
130
|
racc (~> 1.4)
|
131
131
|
public_suffix (4.0.7)
|
132
132
|
racc (1.6.0)
|
@@ -150,7 +150,7 @@ GEM
|
|
150
150
|
rails-dom-testing (2.0.3)
|
151
151
|
activesupport (>= 4.2.0)
|
152
152
|
nokogiri (>= 1.6)
|
153
|
-
rails-html-sanitizer (1.4.
|
153
|
+
rails-html-sanitizer (1.4.3)
|
154
154
|
loofah (~> 2.3)
|
155
155
|
railties (7.0.2.4)
|
156
156
|
actionpack (= 7.0.2.4)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryz310
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- example/api_clients/application_api_client.rb
|
249
249
|
- example/api_clients/my_error_api_client.rb
|
250
250
|
- example/api_clients/my_errors.rb
|
251
|
+
- example/api_clients/my_header_api_client.rb
|
251
252
|
- example/api_clients/my_pagination_api_client.rb
|
252
253
|
- example/api_clients/my_rest_api_client.rb
|
253
254
|
- example/api_clients/my_status_api_client.rb
|
@@ -306,6 +307,7 @@ files:
|
|
306
307
|
- my_api/Rakefile
|
307
308
|
- my_api/app/controllers/application_controller.rb
|
308
309
|
- my_api/app/controllers/error_controller.rb
|
310
|
+
- my_api/app/controllers/header_controller.rb
|
309
311
|
- my_api/app/controllers/pagination_controller.rb
|
310
312
|
- my_api/app/controllers/rest_controller.rb
|
311
313
|
- my_api/app/controllers/status_controller.rb
|
@@ -326,6 +328,7 @@ files:
|
|
326
328
|
- my_api/public/favicon.ico
|
327
329
|
- my_api/public/index.html
|
328
330
|
- my_api/spec/controllers/error_controller_spec.rb
|
331
|
+
- my_api/spec/controllers/header_controller_spec.rb
|
329
332
|
- my_api/spec/controllers/pagination_controller_spec.rb
|
330
333
|
- my_api/spec/controllers/rest_controller_spec.rb
|
331
334
|
- my_api/spec/controllers/status_controller_spec.rb
|