f_http_client 0.3.0 → 0.4.0
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 +4 -4
- data/.release-please-manifest.json +3 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +14 -1
- data/CONTRIBUTING.md +92 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +29 -33
- data/README.md +32 -1
- data/f_http_client.gemspec +43 -0
- data/lib/f_http_client/processor/response.rb +33 -2
- data/lib/f_http_client/version.rb +1 -1
- data/release-please-config.json +18 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7bc7ea9df893eeb1677e578522732aba2ae7f6b4613bdd7621a5ab1e4686f48a
|
|
4
|
+
data.tar.gz: f471ba64951044aab190a13e29f93da1858c45c32d225268f23a4dd4324edde4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2560bfd3e0954a0fa58dc416a76a6018ce3acd41afdb808f04742a56495aae7ee975c87421aeb2f5fd2d95762a8d616a6554653ff5210c06eeb5530d4a6a7c2e
|
|
7
|
+
data.tar.gz: '058d4e67c2ce215ebaa7cddf3fed92a2b964e962530849eb854c7c4af73528352aa4ee5341cb72a3531f11ae9618f6fa15df40691eccae767585ffb07484669b'
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.4.0](https://github.com/Fretadao/f_http_client/compare/v0.3.0...v0.4.0) (2026-08-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* the FService matchers compare the type list for equality, so specs asserting have_failed_with(:unprocessable_entity, :client_error) now need have_failed_with(:unprocessable_content, :unprocessable_entity, :client_error). Runtime is unaffected — on_failure matches by inclusion. Seven specs across apps/router and apps/web need this adjustment.
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* expose RFC 9110 status type aliases for 422 and 413 [CU-86ak35ptc] ([#37](https://github.com/Fretadao/f_http_client/issues/37)) ([277ac96](https://github.com/Fretadao/f_http_client/commit/277ac966c1aad874839445066cc251d2f3ea09e5))
|
|
13
|
+
|
|
14
|
+
## [0.3.0] - 2026-08-19
|
|
2
15
|
|
|
3
16
|
- Add `f_http_client_response_including` RSpec matcher for testing HTTParty::Response objects with nested matchers
|
|
4
17
|
- Fix Ruby 4.0+ compatibility by adding activesupport >= 7.2, ostruct, and csv dependencies
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development setup
|
|
4
|
+
|
|
5
|
+
Run `bin/setup` once after cloning. It installs dependencies and points
|
|
6
|
+
`core.hooksPath` at `.githooks/`, enabling a `commit-msg` hook that enforces
|
|
7
|
+
Conventional Commits locally.
|
|
8
|
+
|
|
9
|
+
Run the linter and the tests the same way CI does:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bundle exec rubocop -c .rubocop.yml --parallel
|
|
13
|
+
bundle exec rspec -fp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Commit messages — Conventional Commits
|
|
17
|
+
|
|
18
|
+
This project follows [Conventional Commits](https://www.conventionalcommits.org/).
|
|
19
|
+
The version bump and the `CHANGELOG.md` are generated automatically from commit
|
|
20
|
+
messages, so the prefix matters:
|
|
21
|
+
|
|
22
|
+
| Type | When to use | Release effect |
|
|
23
|
+
|------|-------------|----------------|
|
|
24
|
+
| `feat:` | New capability | minor bump |
|
|
25
|
+
| `fix:` | Bug fix | patch bump |
|
|
26
|
+
| `feat!:` or a `BREAKING CHANGE:` footer | Backwards-incompatible change | minor bump while `0.x`, major from `1.0` on |
|
|
27
|
+
| `chore:` `ci:` `docs:` `style:` `test:` `refactor:` | Maintenance | no release |
|
|
28
|
+
|
|
29
|
+
Pull requests are squash-merged, so **the PR title becomes the commit message**
|
|
30
|
+
release-please reads. Get the title right even when the individual commits are
|
|
31
|
+
messy.
|
|
32
|
+
|
|
33
|
+
> One thing to keep in mind when changing result types: the FService matchers
|
|
34
|
+
> compare the type list for **equality**, not inclusion. Adding a type to an
|
|
35
|
+
> existing result — say a second alias for a status — breaks every consuming spec
|
|
36
|
+
> that matches the exact list (`have_failed_with(:conflict, :client_error)`), even
|
|
37
|
+
> though `on_failure(:conflict)` hooks keep working. Treat it as a breaking change.
|
|
38
|
+
|
|
39
|
+
## Releasing (release-please)
|
|
40
|
+
|
|
41
|
+
Releases are automated with [release-please](https://github.com/googleapis/release-please);
|
|
42
|
+
there is no version to edit and no tag to create by hand.
|
|
43
|
+
|
|
44
|
+
1. Every push to `master` creates or updates a **release PR** titled
|
|
45
|
+
`chore(master): release X.Y.Z`. It bumps `lib/f_http_client/version.rb`,
|
|
46
|
+
`.release-please-manifest.json` and `Gemfile.lock`, and updates `CHANGELOG.md`
|
|
47
|
+
from the Conventional Commits made since the last release.
|
|
48
|
+
2. **Do not edit `CHANGELOG.md` by hand.** release-please owns it.
|
|
49
|
+
3. **Merging the release PR** creates the git tag `vX.Y.Z` and a GitHub Release.
|
|
50
|
+
That triggers `.github/workflows/publish.yml`, which publishes the gem to
|
|
51
|
+
RubyGems through [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/)
|
|
52
|
+
— OIDC, with no API key stored in this repository. Consumers resolve it normally:
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
gem 'f_http_client', '~> 0.3'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
4. The release PR always reflects **everything on `master` since the last
|
|
59
|
+
release**. Cut releases promptly: merge the release PR before landing
|
|
60
|
+
unrelated work you don't want included.
|
|
61
|
+
|
|
62
|
+
> Why this exists: 0.3.0 was published to RubyGems in February 2026, but the tag
|
|
63
|
+
> `v0.3.0` was never created — the newest tag is still `v0.2.1`, from 2023. So the
|
|
64
|
+
> released code has no reference point in git: no compare link, no way to check out
|
|
65
|
+
> what shipped. Nothing in the manual process caught that, and it had happened
|
|
66
|
+
> silently for a whole release.
|
|
67
|
+
|
|
68
|
+
## If the release PR is failing
|
|
69
|
+
|
|
70
|
+
release-please only rebuilds the release branch when a **releasable** commit
|
|
71
|
+
(`feat:` / `fix:`) lands on `master`. Non-releasable commits (`chore:`, `ci:`,
|
|
72
|
+
`docs:`, `style:`, `test:`) do **not** rebuild it, so the release branch can fall
|
|
73
|
+
behind `master` and its CI can run stale code.
|
|
74
|
+
|
|
75
|
+
When the release PR's CI is red:
|
|
76
|
+
|
|
77
|
+
1. Push the fix to `master` through a normal PR. **Never** push directly to the
|
|
78
|
+
`release-please--…` branch — release-please overwrites it.
|
|
79
|
+
2. If those fix commits are non-releasable (so the release PR won't refresh on its
|
|
80
|
+
own), **close the release PR and delete its branch**. On the next push to
|
|
81
|
+
`master`, release-please recreates it from the current `master`.
|
|
82
|
+
3. Merge the freshly recreated release PR.
|
|
83
|
+
|
|
84
|
+
Never manually rebase or force-push the release-please branch.
|
|
85
|
+
|
|
86
|
+
## If the gem was not published
|
|
87
|
+
|
|
88
|
+
The tag and the GitHub Release already exist, so publishing is retryable: fix the
|
|
89
|
+
cause and use **Re-run jobs** on the failed `Publish gem` workflow run. An
|
|
90
|
+
authentication failure points at the trusted publisher registration on RubyGems
|
|
91
|
+
(the repository and the workflow filename must match `publish.yml`), not at the
|
|
92
|
+
workflow itself.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
f_http_client (0.
|
|
4
|
+
f_http_client (0.4.0)
|
|
5
5
|
activesupport (>= 7.2)
|
|
6
6
|
addressable
|
|
7
7
|
dry-configurable
|
|
@@ -12,7 +12,7 @@ PATH
|
|
|
12
12
|
GEM
|
|
13
13
|
remote: https://rubygems.org/
|
|
14
14
|
specs:
|
|
15
|
-
activesupport (8.1.
|
|
15
|
+
activesupport (8.1.3.1)
|
|
16
16
|
base64
|
|
17
17
|
bigdecimal
|
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
@@ -25,21 +25,20 @@ GEM
|
|
|
25
25
|
securerandom (>= 0.3)
|
|
26
26
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
27
27
|
uri (>= 0.13.1)
|
|
28
|
-
addressable (2.
|
|
28
|
+
addressable (2.9.0)
|
|
29
29
|
public_suffix (>= 2.0.2, < 8.0)
|
|
30
30
|
ast (2.4.3)
|
|
31
31
|
base64 (0.3.0)
|
|
32
32
|
benchmark (0.5.0)
|
|
33
|
-
bigdecimal (4.
|
|
33
|
+
bigdecimal (4.1.2)
|
|
34
34
|
coderay (1.1.3)
|
|
35
|
-
concurrent-ruby (1.3.
|
|
35
|
+
concurrent-ruby (1.3.8)
|
|
36
36
|
connection_pool (3.0.2)
|
|
37
37
|
crack (1.0.1)
|
|
38
38
|
bigdecimal
|
|
39
39
|
rexml
|
|
40
|
-
csv (3.3.
|
|
40
|
+
csv (3.3.6)
|
|
41
41
|
diff-lcs (1.6.2)
|
|
42
|
-
docile (1.4.1)
|
|
43
42
|
drb (2.2.3)
|
|
44
43
|
dry-configurable (1.3.0)
|
|
45
44
|
dry-core (~> 1.1)
|
|
@@ -49,27 +48,28 @@ GEM
|
|
|
49
48
|
logger
|
|
50
49
|
zeitwerk (~> 2.6)
|
|
51
50
|
dry-initializer (3.2.0)
|
|
52
|
-
f_service (0.
|
|
51
|
+
f_service (0.4.1)
|
|
53
52
|
hashdiff (1.2.1)
|
|
54
53
|
httparty (0.24.2)
|
|
55
54
|
csv
|
|
56
55
|
mini_mime (>= 1.0.0)
|
|
57
56
|
multi_xml (>= 0.5.2)
|
|
58
|
-
i18n (1.
|
|
57
|
+
i18n (1.15.2)
|
|
59
58
|
concurrent-ruby (~> 1.0)
|
|
60
|
-
json (2.
|
|
61
|
-
language_server-protocol (3.17.0.
|
|
59
|
+
json (2.21.2)
|
|
60
|
+
language_server-protocol (3.17.0.6)
|
|
62
61
|
lint_roller (1.1.0)
|
|
63
62
|
logger (1.7.0)
|
|
64
63
|
method_source (1.1.0)
|
|
65
64
|
mini_mime (1.1.5)
|
|
66
|
-
minitest (6.0.
|
|
65
|
+
minitest (6.0.6)
|
|
66
|
+
drb (~> 2.0)
|
|
67
67
|
prism (~> 1.5)
|
|
68
68
|
multi_xml (0.8.1)
|
|
69
69
|
bigdecimal (>= 3.1, < 5)
|
|
70
70
|
ostruct (0.6.3)
|
|
71
|
-
parallel (1.
|
|
72
|
-
parser (3.3.
|
|
71
|
+
parallel (1.28.0)
|
|
72
|
+
parser (3.3.12.0)
|
|
73
73
|
ast (~> 2.4.1)
|
|
74
74
|
racc
|
|
75
75
|
prism (1.9.0)
|
|
@@ -78,11 +78,11 @@ GEM
|
|
|
78
78
|
method_source (~> 1.0)
|
|
79
79
|
pry-nav (1.0.0)
|
|
80
80
|
pry (>= 0.9.10, < 0.15)
|
|
81
|
-
public_suffix (7.0.
|
|
81
|
+
public_suffix (7.0.5)
|
|
82
82
|
racc (1.8.1)
|
|
83
83
|
rainbow (3.1.1)
|
|
84
|
-
rake (13.
|
|
85
|
-
regexp_parser (2.
|
|
84
|
+
rake (13.4.2)
|
|
85
|
+
regexp_parser (2.12.0)
|
|
86
86
|
rexml (3.4.4)
|
|
87
87
|
rspec (3.13.2)
|
|
88
88
|
rspec-core (~> 3.13.0)
|
|
@@ -97,46 +97,42 @@ GEM
|
|
|
97
97
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
98
98
|
rspec-support (~> 3.13.0)
|
|
99
99
|
rspec-support (3.13.7)
|
|
100
|
-
rubocop (1.
|
|
100
|
+
rubocop (1.89.0)
|
|
101
101
|
json (~> 2.3)
|
|
102
102
|
language_server-protocol (~> 3.17.0.2)
|
|
103
103
|
lint_roller (~> 1.1.0)
|
|
104
|
-
parallel (
|
|
104
|
+
parallel (>= 1.10)
|
|
105
105
|
parser (>= 3.3.0.2)
|
|
106
106
|
rainbow (>= 2.2.2, < 4.0)
|
|
107
107
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
108
108
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
109
109
|
ruby-progressbar (~> 1.7)
|
|
110
110
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
111
|
-
rubocop-ast (1.
|
|
111
|
+
rubocop-ast (1.50.0)
|
|
112
112
|
parser (>= 3.3.7.2)
|
|
113
113
|
prism (~> 1.7)
|
|
114
|
-
rubocop-performance (1.
|
|
114
|
+
rubocop-performance (1.27.0)
|
|
115
115
|
lint_roller (~> 1.1)
|
|
116
|
-
rubocop (>= 1.
|
|
116
|
+
rubocop (>= 1.89.0, < 2.0)
|
|
117
117
|
rubocop-ast (>= 1.47.1, < 2.0)
|
|
118
|
-
rubocop-rspec (3.
|
|
118
|
+
rubocop-rspec (3.10.2)
|
|
119
119
|
lint_roller (~> 1.1)
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
regexp_parser (>= 2.0)
|
|
121
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
122
|
+
rubocop-vicenzo (0.6.0)
|
|
122
123
|
lint_roller (~> 1.1)
|
|
123
124
|
rubocop (>= 1.72.2)
|
|
124
125
|
rubocop-rspec (>= 3.5.0)
|
|
125
126
|
ruby-progressbar (1.13.0)
|
|
126
127
|
securerandom (0.4.1)
|
|
127
|
-
simplecov (
|
|
128
|
-
docile (~> 1.1)
|
|
129
|
-
simplecov-html (~> 0.11)
|
|
130
|
-
simplecov_json_formatter (~> 0.1)
|
|
131
|
-
simplecov-html (0.13.2)
|
|
132
|
-
simplecov_json_formatter (0.1.4)
|
|
128
|
+
simplecov (1.1.1)
|
|
133
129
|
tzinfo (2.0.6)
|
|
134
130
|
concurrent-ruby (~> 1.0)
|
|
135
131
|
unicode-display_width (3.2.0)
|
|
136
132
|
unicode-emoji (~> 4.1)
|
|
137
133
|
unicode-emoji (4.2.0)
|
|
138
134
|
uri (1.1.1)
|
|
139
|
-
webmock (3.26.
|
|
135
|
+
webmock (3.26.2)
|
|
140
136
|
addressable (>= 2.8.0)
|
|
141
137
|
crack (>= 0.3.2)
|
|
142
138
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
@@ -154,7 +150,7 @@ DEPENDENCIES
|
|
|
154
150
|
pry
|
|
155
151
|
pry-nav
|
|
156
152
|
racc
|
|
157
|
-
rake (~> 13.
|
|
153
|
+
rake (~> 13.4)
|
|
158
154
|
rspec (~> 3.0)
|
|
159
155
|
rubocop
|
|
160
156
|
rubocop-performance
|
data/README.md
CHANGED
|
@@ -93,13 +93,44 @@ Result examples:
|
|
|
93
93
|
```rb
|
|
94
94
|
Person::Create.(name: 'Joe Vicenzo', birthdate: '2000-01-01')
|
|
95
95
|
.and_then { |user| return redirect_to users_path(user.id) }
|
|
96
|
-
.on_failure(:
|
|
96
|
+
.on_failure(:unprocessable_content) { |errors| return render_action :new, locals: { errors: errors } }
|
|
97
97
|
.on_failure(:client_error) { |errors| render_action :new, warning: errors }
|
|
98
98
|
.on_failure(:server_error) { |error| render_action :new, warning: ['Try again latter.'] }
|
|
99
99
|
.on_failure(:server_error) { |error| render_action :new, warning: ['Server is busy. Try again latter.'] }
|
|
100
100
|
.on_failure { |_error, type| render_action :new, warning: ["Unexpected error. Contact admin and talk about #{type} error."] }
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
### Status names renamed by RFC 9110
|
|
104
|
+
|
|
105
|
+
The failure/success type comes from the `Net::HTTPResponse` class name, which still carries the
|
|
106
|
+
pre-RFC 9110 names for two status codes. Rack 3.1+ — and therefore every Rails app — already
|
|
107
|
+
canonicalized them. For those two codes the result carries **both** symbols as types, canonical
|
|
108
|
+
first, so either name matches:
|
|
109
|
+
|
|
110
|
+
| Status | Canonical type (Rack 3.1+) | Legacy type (still matches) |
|
|
111
|
+
|--------|----------------------------|-----------------------------|
|
|
112
|
+
| 422 | `:unprocessable_content` | `:unprocessable_entity` |
|
|
113
|
+
| 413 | `:content_too_large` | `:payload_too_large` |
|
|
114
|
+
|
|
115
|
+
```rb
|
|
116
|
+
# A 422 response yields the types below, in this order:
|
|
117
|
+
# [:unprocessable_content, :unprocessable_entity, :client_error]
|
|
118
|
+
|
|
119
|
+
Person::Create.(name: 'Joe Vicenzo')
|
|
120
|
+
.on_failure(:unprocessable_content) { |errors| render_action :new, locals: { errors: errors } }
|
|
121
|
+
.on_failure(:unprocessable_entity) { |errors| render_action :new, locals: { errors: errors } }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Prefer the canonical name: an untyped `on_failure` receives it as the `type`, and the legacy one is
|
|
125
|
+
kept only to ease the migration — it will be dropped in a future major release.
|
|
126
|
+
|
|
127
|
+
If you assert on types with the FService matchers, note that `have_failed_with` compares the whole
|
|
128
|
+
type list, so specs covering those two codes need the full trio:
|
|
129
|
+
|
|
130
|
+
```rb
|
|
131
|
+
expect(result).to have_failed_with(:unprocessable_content, :unprocessable_entity, :client_error)
|
|
132
|
+
```
|
|
133
|
+
|
|
103
134
|
This gem uses the gem [HTTParty](https://github.com/jnunemaker/httparty) as base to perform requests.
|
|
104
135
|
Then we can use any [example](https://github.com/jnunemaker/httparty/tree/master/examples) to implements the method make_request, for GET, POST, PUT, etc.
|
|
105
136
|
The class *FHTTPClient::Base* provides the following options to help building the request:
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/f_http_client/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'f_http_client'
|
|
7
|
+
spec.version = FHTTPClient::VERSION
|
|
8
|
+
spec.authors = ['Fretadao Tech Team']
|
|
9
|
+
spec.email = ['tech@fretadao.com.br']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Gem to provade a base for an HTTP client using FService architecture'
|
|
12
|
+
spec.homepage = 'https://github.com/Fretadao/f_http_client'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
|
+
spec.required_ruby_version = '>= 3.2.0'
|
|
15
|
+
|
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/Fretadao/f_http_client/blob/master/CHANGELOG.md'
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
24
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = 'exe'
|
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ['lib']
|
|
30
|
+
|
|
31
|
+
# Uncomment to register a new dependency of your gem
|
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
33
|
+
spec.add_dependency 'activesupport', '>= 7.2'
|
|
34
|
+
spec.add_dependency 'addressable'
|
|
35
|
+
spec.add_dependency 'dry-configurable'
|
|
36
|
+
spec.add_dependency 'dry-initializer'
|
|
37
|
+
spec.add_dependency 'f_service', '>= 0.3.0'
|
|
38
|
+
spec.add_dependency 'httparty'
|
|
39
|
+
|
|
40
|
+
# For more information and examples about making a new gem, check out our
|
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
42
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
|
43
|
+
end
|
|
@@ -34,6 +34,24 @@ module FHTTPClient
|
|
|
34
34
|
|
|
35
35
|
private_constant :STATUS_FAMILIES
|
|
36
36
|
|
|
37
|
+
# Status codes whose canonical name changed with RFC 9110. The type comes from
|
|
38
|
+
# Net::HTTPResponse::CODE_TO_OBJ, which still carries the pre-RFC names, while Rack
|
|
39
|
+
# 3.1+ (and therefore every Rails app consuming this gem) already canonicalized them.
|
|
40
|
+
# Emitting both symbols, canonical first, lets `on_failure` match either name so
|
|
41
|
+
# consumers can migrate at their own pace.
|
|
42
|
+
#
|
|
43
|
+
# TODO: Drop this constant and #response_types once net-http adopts the RFC 9110 names
|
|
44
|
+
# (or the status-to-type source stops being CODE_TO_OBJ) AND consumers have migrated
|
|
45
|
+
# off the legacy names. See Rack::Utils OBSOLETE_SYMBOL_MAPPINGS (rack >= 3.1).
|
|
46
|
+
RENAMED_TYPES = {
|
|
47
|
+
unprocessable_entity: %i[unprocessable_content unprocessable_entity],
|
|
48
|
+
unprocessable_content: %i[unprocessable_content unprocessable_entity],
|
|
49
|
+
payload_too_large: %i[content_too_large payload_too_large],
|
|
50
|
+
content_too_large: %i[content_too_large payload_too_large]
|
|
51
|
+
}.freeze
|
|
52
|
+
|
|
53
|
+
private_constant :RENAMED_TYPES
|
|
54
|
+
|
|
37
55
|
def run
|
|
38
56
|
log_data.and_then { success? ? success_response : failure_response }
|
|
39
57
|
end
|
|
@@ -43,11 +61,24 @@ module FHTTPClient
|
|
|
43
61
|
def_delegators :@response, :headers, :success?, :parsed_response, :code
|
|
44
62
|
|
|
45
63
|
def success_response
|
|
46
|
-
Success(
|
|
64
|
+
Success(*response_types, response_family, data: response)
|
|
47
65
|
end
|
|
48
66
|
|
|
49
67
|
def failure_response
|
|
50
|
-
Failure(
|
|
68
|
+
Failure(*response_types, response_family, data: response)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Private:
|
|
72
|
+
# Result types for the response status, from the canonical name to the legacy one.
|
|
73
|
+
# Ex: When the request returns a 422 (Unprocessable Content)
|
|
74
|
+
#
|
|
75
|
+
# # => [:unprocessable_content, :unprocessable_entity]
|
|
76
|
+
#
|
|
77
|
+
# Ex: When the request returns a 404 (Not Found)
|
|
78
|
+
#
|
|
79
|
+
# # => [:not_found]
|
|
80
|
+
def response_types
|
|
81
|
+
RENAMED_TYPES.fetch(response_type) { [response_type] }
|
|
51
82
|
end
|
|
52
83
|
|
|
53
84
|
# Private:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
|
3
|
+
"bump-minor-pre-major": true,
|
|
4
|
+
"include-component-in-tag": false,
|
|
5
|
+
"packages": {
|
|
6
|
+
".": {
|
|
7
|
+
"release-type": "ruby",
|
|
8
|
+
"package-name": "f_http_client",
|
|
9
|
+
"version-file": "lib/f_http_client/version.rb",
|
|
10
|
+
"extra-files": [
|
|
11
|
+
{
|
|
12
|
+
"type": "generic",
|
|
13
|
+
"path": "spec/f_http_client_spec.rb"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: f_http_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fretadao Tech Team
|
|
@@ -99,15 +99,18 @@ executables: []
|
|
|
99
99
|
extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
|
101
101
|
files:
|
|
102
|
+
- ".release-please-manifest.json"
|
|
102
103
|
- ".rspec"
|
|
103
104
|
- ".rubocop.yml"
|
|
104
105
|
- CHANGELOG.md
|
|
106
|
+
- CONTRIBUTING.md
|
|
105
107
|
- Gemfile
|
|
106
108
|
- Gemfile.lock
|
|
107
109
|
- LICENSE
|
|
108
110
|
- README.md
|
|
109
111
|
- Rakefile
|
|
110
112
|
- examples/post_find.rb
|
|
113
|
+
- f_http_client.gemspec
|
|
111
114
|
- lib/f_http_client.rb
|
|
112
115
|
- lib/f_http_client/base.rb
|
|
113
116
|
- lib/f_http_client/cache/http_response_analizer.rb
|
|
@@ -132,6 +135,7 @@ files:
|
|
|
132
135
|
- lib/f_http_client/service.rb
|
|
133
136
|
- lib/f_http_client/store.rb
|
|
134
137
|
- lib/f_http_client/version.rb
|
|
138
|
+
- release-please-config.json
|
|
135
139
|
- sig/f_http_client.rbs
|
|
136
140
|
homepage: https://github.com/Fretadao/f_http_client
|
|
137
141
|
licenses:
|
|
@@ -148,14 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
148
152
|
requirements:
|
|
149
153
|
- - ">="
|
|
150
154
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: 3.
|
|
155
|
+
version: 3.2.0
|
|
152
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
157
|
requirements:
|
|
154
158
|
- - ">="
|
|
155
159
|
- !ruby/object:Gem::Version
|
|
156
160
|
version: '0'
|
|
157
161
|
requirements: []
|
|
158
|
-
rubygems_version:
|
|
162
|
+
rubygems_version: 3.6.9
|
|
159
163
|
specification_version: 4
|
|
160
164
|
summary: Gem to provade a base for an HTTP client using FService architecture
|
|
161
165
|
test_files: []
|