httpigeon 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release-please.yaml +6 -3
- data/CHANGELOG.md +14 -0
- data/README.md +15 -9
- data/bin/console +1 -2
- data/lib/httpigeon/request.rb +24 -8
- data/lib/httpigeon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 500fac14ff3591858c0547ea049891de72ffa58747e76ddb1f5faf3cd2a12ba8
|
4
|
+
data.tar.gz: 2f6bce6c474bed8bd6cf9168b8f4271a7d4483145d89a5674a72ce6f83c88ac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 114d33029253f8ebd4a9dac5e8815f59b1d8a369ab9be4e971d1711da8df4f24618885876902138bd4d7c4888dd89a7d108da8c82296a8d1c996071c5444141f
|
7
|
+
data.tar.gz: fe8312258406cd6f78a162ce3f5f704afcb4091526083802a1bb724b759d5481ff859f885099ecbaacae888df72378e24c7cebb7c1c79704c4ba141b2a92aba8
|
@@ -1,5 +1,8 @@
|
|
1
1
|
name: release-please
|
2
|
-
on:
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
3
6
|
|
4
7
|
jobs:
|
5
8
|
release-please:
|
@@ -19,8 +22,8 @@ jobs:
|
|
19
22
|
publish-gem:
|
20
23
|
uses: ./.github/workflows/publish.yaml
|
21
24
|
needs: [ release-please ]
|
22
|
-
|
25
|
+
if: needs.release-please.outputs.release_created
|
23
26
|
with:
|
24
27
|
public_publish: 'true'
|
25
|
-
private_publish: '
|
28
|
+
private_publish: 'true'
|
26
29
|
secrets: inherit # implicitly forward secrets to called workflow
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.1.0](https://github.com/dailypay/httpigeon/compare/v2.0.1...v2.1.0) (2024-01-05)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* **response:** [NO-TICKET] parsed_response tests and json support ([#31](https://github.com/dailypay/httpigeon/issues/31)) ([e169215](https://github.com/dailypay/httpigeon/commit/e169215e1394927cb9137e1691196aa535ffd25d))
|
9
|
+
|
10
|
+
## [2.0.1](https://github.com/dailypay/httpigeon/compare/v2.0.0...v2.0.1) (2023-12-21)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* **request:** Handle edge cases in response parsing ([#29](https://github.com/dailypay/httpigeon/issues/29)) ([7818562](https://github.com/dailypay/httpigeon/commit/7818562736b5c5258b77357c73f24926e46eb458))
|
16
|
+
|
3
17
|
## [2.0.0](https://github.com/dailypay/httpigeon/compare/v1.3.0...v2.0.0) (2023-10-25)
|
4
18
|
|
5
19
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# HTTPigeon
|
1
|
+
# HTTPigeon [![Gem Version](https://badge.fury.io/rb/httpigeon.svg)](https://badge.fury.io/rb/httpigeon)
|
2
2
|
|
3
3
|
As early as 2000 years ago, and as late as 20 years ago, messenger pigeons (a.k.a homing pigeons) were an established and reliable means of long distance communication. This library is dedicated to messenger pigeons and all their contributions towards ancient and modern civilization ❤️.
|
4
4
|
|
@@ -21,12 +21,18 @@ end
|
|
21
21
|
```
|
22
22
|
|
23
23
|
**Instantiating with a block:**
|
24
|
+
|
25
|
+
- **NOTE:** This pretty much works the same way as passing a block to `Faraday.new`. Any config you can use with `Faraday` directly, you can do with `HTTPigeon::Request`
|
26
|
+
|
24
27
|
```ruby
|
28
|
+
require "faraday/retry"
|
29
|
+
|
25
30
|
# @option [String] base_url the base URI (required)
|
26
|
-
request = HTTPigeon::Request.new(base_url: 'https://dummyjson.com') do |
|
27
|
-
#
|
28
|
-
|
29
|
-
|
31
|
+
request = HTTPigeon::Request.new(base_url: 'https://dummyjson.com') do |config|
|
32
|
+
# config is an instance of Faraday::Connection
|
33
|
+
config.headers['foo'] = 'barzzz'
|
34
|
+
config.options['timeout'] = 15
|
35
|
+
config.request :retry, { max: 5 }
|
30
36
|
...
|
31
37
|
end
|
32
38
|
|
@@ -46,7 +52,7 @@ request.run(path: '/users/1')
|
|
46
52
|
# @param event_type [String] for filtering/scoping the logs (default: 'http.outbound')
|
47
53
|
# @param log_filters [Array<Symbol, String>] specifies keys in URL, headers and body to be redacted before logging.
|
48
54
|
# Can define keys for both Hash and String payloads (default: [])
|
49
|
-
request = HTTPigeon::Request.new(base_url: 'https://dummyjson.com', headers: { Accept: 'application/json' }, log_filters: [:api_key, 'access_token', '(client_id=)(\w+)'])
|
55
|
+
request = HTTPigeon::Request.new(base_url: 'https://dummyjson.com', headers: { Accept: 'application/json' }, log_filters: [:api_key, 'access_token', '/(client_id=)(\w+)/'])
|
50
56
|
request.run(path: '/users/1')
|
51
57
|
```
|
52
58
|
|
@@ -120,9 +126,9 @@ Examples assume you set `:redactor_string` in your initializer to `[REDACTED]`
|
|
120
126
|
| `"email"` OR `:email` | Hash | `{ "email": "atuny0@sohu.com" }` | `{ "email": "atu...[REDACTED]" }` | Filters will get applied to nested objects as well. There's no limit on depth |
|
121
127
|
| `"email::[REDACTED]"` | Hash | `{ "email": "atuny0@sohu.com" }` | `{ "email": "[REDACTED]" }` | Replacement can be whatever you want and is applied as-is |
|
122
128
|
| `"/email/"` | Hash | `{ "email": "atuny0@sohu.com" }` | `{ "email": "atuny0@sohu.com" }` | Regex filters will not get applied to hash keys. This is a design decision to prevent bugs |
|
123
|
-
| `"/(email=)(
|
124
|
-
| `"/email
|
125
|
-
| `"(email=)(
|
129
|
+
| `"/(email=)(.*\.[a-z]+)(&\|$)/"` | String | `https://dummyjson.com/users?email=atuny0@sohu.com` | `https://dummyjson.com/users?email=atu...[REDACTED]` | Regex filters must be in proper regex format but wrapped in a string. If no replacement is specified, [regex grouping](https://learn.microsoft.com/en-us/dotnet/standard/base-types/grouping-constructs-in-regular-expressions) MUST be used |
|
130
|
+
| `"/email=.*\.[a-z]+(&\|$)/::email=[REDACTED]"` | String | `https://dummyjson.com/users?email=atuny0@sohu.com` | `https://dummyjson.com/users?email=[REDACTED]` | Replacement can be whatever you want and is applied as-is. No need to use regex grouping when explicitly specifying a replacement |
|
131
|
+
| `"(email=)(.*\.[a-z]+)(&\|$)"` OR `"email"` | String | `https://dummyjson.com/users?email=atuny0@sohu.com` | `https://dummyjson.com/users?email=atuny0@sohu.com` | String regex filters must be wrapped in forward slashes(i.e `/[you-regex]/`), otherwise they will be ignored. This is a design descision to prevent bugs |
|
126
132
|
|
127
133
|
There are some ready-made, tokenized filter patterns available that you can take advantage of for **URLs** and/or **URI encoded requests**:
|
128
134
|
- HTTPigeon::FilterPatterns::EMAIL
|
data/bin/console
CHANGED
@@ -7,8 +7,7 @@ require "httpigeon"
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
9
9
|
|
10
|
-
|
11
|
-
# require "pry"
|
10
|
+
require "pry"
|
12
11
|
# Pry.start
|
13
12
|
|
14
13
|
require "irb"
|
data/lib/httpigeon/request.rb
CHANGED
@@ -32,12 +32,14 @@ module HTTPigeon
|
|
32
32
|
|
33
33
|
def initialize(base_url:, options: nil, headers: nil, adapter: nil, logger: nil, event_type: nil, log_filters: nil)
|
34
34
|
@base_url = base_url
|
35
|
-
@event_type = event_type
|
36
|
-
@log_filters = log_filters || []
|
37
|
-
@logger = logger || default_logger
|
38
35
|
|
39
36
|
request_headers = default_headers.merge(headers.to_h)
|
40
|
-
|
37
|
+
|
38
|
+
base_connection = Faraday.new(url: base_url).tap do |config|
|
39
|
+
config.headers.deep_merge!(request_headers)
|
40
|
+
config.options.merge!(options.to_h)
|
41
|
+
config.response :httpigeon_logger, logger if logger.is_a?(HTTPigeon::Logger)
|
42
|
+
end
|
41
43
|
|
42
44
|
@connection = if block_given?
|
43
45
|
yield(base_connection) && base_connection
|
@@ -47,7 +49,7 @@ module HTTPigeon
|
|
47
49
|
faraday.options.merge!(options.to_h)
|
48
50
|
faraday.request :url_encoded
|
49
51
|
faraday.adapter adapter || Faraday.default_adapter
|
50
|
-
faraday.response :httpigeon_logger,
|
52
|
+
faraday.response :httpigeon_logger, default_logger(event_type, log_filters) unless logger.is_a?(HTTPigeon::Logger)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
@@ -67,15 +69,29 @@ module HTTPigeon
|
|
67
69
|
|
68
70
|
private
|
69
71
|
|
70
|
-
attr_reader :
|
72
|
+
attr_reader :logger, :event_type, :log_filters
|
71
73
|
|
72
74
|
def parse_response
|
73
|
-
JSON.parse(response_body)
|
75
|
+
parsed_body = response_body.is_a?(String) ? JSON.parse(response_body) : response_body
|
76
|
+
deep_with_indifferent_access(parsed_body)
|
74
77
|
rescue JSON::ParserError
|
75
78
|
response_body.presence
|
76
79
|
end
|
77
80
|
|
78
|
-
def
|
81
|
+
def deep_with_indifferent_access(obj)
|
82
|
+
case obj
|
83
|
+
when Hash
|
84
|
+
obj.transform_values do |value|
|
85
|
+
deep_with_indifferent_access(value)
|
86
|
+
end.with_indifferent_access
|
87
|
+
when Array
|
88
|
+
obj.map { |item| deep_with_indifferent_access(item) }
|
89
|
+
else
|
90
|
+
obj
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def default_logger(event_type, log_filters)
|
79
95
|
HTTPigeon::Logger.new(event_type: event_type, log_filters: log_filters)
|
80
96
|
end
|
81
97
|
|
data/lib/httpigeon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpigeon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 2k-joker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|