opinionated_http 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opinionated_http/client.rb +2 -8
- data/lib/opinionated_http/request.rb +2 -3
- data/lib/opinionated_http/response.rb +4 -0
- data/lib/opinionated_http/version.rb +1 -1
- data/test/request_test.rb +2 -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: cbd58bf8946567e33344521051ead26e88ad8d6d083f820c1528ac644c6ac7ae
|
4
|
+
data.tar.gz: 4dd8282607215174ef3b261f262e9bbbd99396a0f5992df1a6dc652bc58b4008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37c91ccf2069493d1cea1243d5673d3fbbd7e7caed6542eb3b61678e1f4f2f34fd964b5521b17042f297482f42921983a5019c788b5b3de10d6739a1d9569239
|
7
|
+
data.tar.gz: fd93c9925f575faabc06809cd0ed665469cd8e2531c91b9a96446e00b64fb1be1b50c3a065378ea73697a0c42f563a352c234dc42f9b8ac309e5413e2accc253
|
@@ -147,14 +147,8 @@ module OpinionatedHTTP
|
|
147
147
|
http_method = request.method.upcase
|
148
148
|
response =
|
149
149
|
begin
|
150
|
-
|
151
|
-
|
152
|
-
# payload[:parameters] = parameters
|
153
|
-
payload[:path] = request.path
|
154
|
-
end
|
155
|
-
message = "HTTP #{http_method}: #{action}" if logger.debug?
|
156
|
-
|
157
|
-
logger.benchmark_info(message: message, metric: "#{metric_prefix}/#{action}", payload: payload) do
|
150
|
+
message = "HTTP #{http_method}: #{action} #{request.path}"
|
151
|
+
logger.benchmark_info(message: message, metric: "#{metric_prefix}/#{action}") do
|
158
152
|
driver.request(request)
|
159
153
|
end
|
160
154
|
rescue StandardError => e
|
@@ -51,12 +51,11 @@ module OpinionatedHTTP
|
|
51
51
|
private
|
52
52
|
|
53
53
|
def format_body
|
54
|
-
return if body.nil?
|
55
|
-
|
56
54
|
case format
|
57
55
|
when :json
|
58
56
|
headers["Content-Type"] = "application/json"
|
59
|
-
|
57
|
+
headers["Accept"] = "application/json"
|
58
|
+
body.is_a?(String) || body.nil? ? body : body.to_json
|
60
59
|
when nil
|
61
60
|
body
|
62
61
|
else
|
@@ -25,6 +25,10 @@ module OpinionatedHTTP
|
|
25
25
|
def body!
|
26
26
|
return body if success?
|
27
27
|
|
28
|
+
exception!
|
29
|
+
end
|
30
|
+
|
31
|
+
def exception!
|
28
32
|
error_message = "HTTP #{verb.upcase}: #{action} Failure: (#{code}) #{message}"
|
29
33
|
logger.error(message: error_message, metric: "#{metric_prefix}/exception", payload: {body: body})
|
30
34
|
raise(error_class, error_message)
|
data/test/request_test.rb
CHANGED
@@ -25,7 +25,8 @@ class RequestTest < Minitest::Test
|
|
25
25
|
req = OpinionatedHTTP::Request.new(action: action, path: path, verb: post_verb, format: :json, body: json_request).http_request
|
26
26
|
|
27
27
|
assert_equal json_request.to_json, req.body
|
28
|
-
assert_equal "application/json", req["
|
28
|
+
assert_equal "application/json", req["content-type"], -> { req.to_hash.ai }
|
29
|
+
assert_equal "application/json", req["accept"], -> { req.to_hash.ai }
|
29
30
|
end
|
30
31
|
|
31
32
|
it "returns a request with supplied headers" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opinionated_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: persistent_http
|