foucault_http 0.4.11 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foucault_http/http_connection.rb +4 -4
- data/lib/foucault_http/http_port.rb +12 -8
- data/lib/foucault_http/net.rb +5 -4
- data/lib/foucault_http/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: f713a32d7cf2653ee97bc088d52395790834fb2f31b7b38b042d8d1ce1da43aa
|
4
|
+
data.tar.gz: 3d7e950145225c23cf7f34c51518d0856adf678b9335ed7a88cc71d71ab196e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40b5184e7a4c85d405a3d37d70c557671724dfad5638fc1ca091ab53c125b7c52725c16dcb3e792f32c50b8d054c46f0f6d4a04ffd3217cf76cd8820aa78999
|
7
|
+
data.tar.gz: 3d5907000303d178f0a9118cedde9716c45efe6299ebcbf3d8c28f6206616e5228ff2dd2320fa24551e45e478e290a2a7736daab50ec92474950e2f8bd8de9b1
|
@@ -10,8 +10,8 @@ module FoucaultHttp
|
|
10
10
|
|
11
11
|
HTTP_CONNECTION_FAILURE = :http_connection_failure
|
12
12
|
|
13
|
-
def connection(address, encoding, cache_store = nil, instrumenter = nil)
|
14
|
-
@http_connection = Try { http_connection(address, encoding, cache_store, instrumenter) }
|
13
|
+
def connection(address, opts, encoding, cache_store = nil, instrumenter = nil)
|
14
|
+
@http_connection = Try { http_connection(address, opts, encoding, cache_store, instrumenter) }
|
15
15
|
self
|
16
16
|
end
|
17
17
|
|
@@ -47,8 +47,8 @@ module FoucaultHttp
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def http_connection(address, encoding, cache_store, instrumenter)
|
51
|
-
faraday_connection = Faraday.new(:
|
50
|
+
def http_connection(address, opts={}, encoding, cache_store, instrumenter)
|
51
|
+
faraday_connection = Faraday.new(opts.merge(url: address)) do |faraday|
|
52
52
|
# faraday.use :http_cache, caching if caching
|
53
53
|
faraday.request encoding if encoding
|
54
54
|
if Configuration.config.logger && Configuration.config.log_formatter
|
@@ -18,32 +18,32 @@ module FoucaultHttp
|
|
18
18
|
class << self
|
19
19
|
|
20
20
|
def post
|
21
|
-
-> correlation, service, resource, hdrs, body_fn, enc, body {
|
21
|
+
-> correlation, service, resource, opts, hdrs, body_fn, enc, body {
|
22
22
|
( Fn.either.(net_ok).(Monad.success).(Monad.failure) <<
|
23
23
|
log_response.(correlation, service, resource, __method__) <<
|
24
24
|
response_value <<
|
25
25
|
run_post.(hdrs, body_fn, body) <<
|
26
|
-
addressed.(service, resource)).(connection.(enc))
|
26
|
+
addressed.(service, resource)).(connection.(opts, enc))
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
30
|
def get
|
31
|
-
-> correlation, service, resource, hdrs, enc, query {
|
31
|
+
-> correlation, service, resource, opts, hdrs, enc, query {
|
32
32
|
( Fn.either.(net_ok).(Monad.success).(Monad.failure) <<
|
33
33
|
log_response.(correlation, service, resource, __method__) <<
|
34
34
|
response_value <<
|
35
35
|
run_get.(hdrs, query) <<
|
36
|
-
addressed.(service, resource)).(connection.(enc))
|
36
|
+
addressed.(service, resource)).(connection.(opts, enc))
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
40
|
def delete
|
41
|
-
-> correlation, service, resource, hdrs {
|
41
|
+
-> correlation, service, resource, opts, hdrs {
|
42
42
|
( Fn.either.(net_ok).(Monad.success).(Monad.failure) <<
|
43
43
|
log_response.([], service, resource, __method__) <<
|
44
44
|
response_value <<
|
45
45
|
run_delete.(hdrs) <<
|
46
|
-
addressed.(service, resource)).(connection.(nil))
|
46
|
+
addressed.(service, resource)).(connection.(opts, nil))
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
@@ -73,7 +73,7 @@ module FoucaultHttp
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def connection
|
76
|
-
-> encoding, address { HttpConnection.new.connection(address, encoding) }.curry
|
76
|
+
-> opts, encoding, address { HttpConnection.new.connection(address, opts, encoding) }.curry
|
77
77
|
end
|
78
78
|
|
79
79
|
def address
|
@@ -140,7 +140,7 @@ module FoucaultHttp
|
|
140
140
|
when "application/json"
|
141
141
|
json_parser
|
142
142
|
when "application/xml", "application/soap+xml", "text/xml"
|
143
|
-
|
143
|
+
xml_parser
|
144
144
|
else
|
145
145
|
nil_parser
|
146
146
|
end
|
@@ -177,6 +177,10 @@ module FoucaultHttp
|
|
177
177
|
-> response { JSON.parse(response.body) }
|
178
178
|
end
|
179
179
|
|
180
|
+
def xml_parser
|
181
|
+
-> response { Nokogiri::XML(response.body) }
|
182
|
+
end
|
183
|
+
|
180
184
|
def text_parser
|
181
185
|
-> response { response.body }
|
182
186
|
end
|
data/lib/foucault_http/net.rb
CHANGED
@@ -9,9 +9,10 @@ module FoucaultHttp
|
|
9
9
|
class << self
|
10
10
|
|
11
11
|
# Client interface
|
12
|
+
|
12
13
|
def post
|
13
|
-
-> correlation, service, resource, hdrs, enc, body_fn, body {
|
14
|
-
HttpPort.post.(correlation, service, resource, hdrs, body_fn, enc, body)
|
14
|
+
-> correlation, service, resource, opts, hdrs, enc, body_fn, body {
|
15
|
+
HttpPort.post.(correlation, service, resource, opts, hdrs, body_fn, enc, body)
|
15
16
|
}.curry
|
16
17
|
end
|
17
18
|
|
@@ -30,8 +31,8 @@ module FoucaultHttp
|
|
30
31
|
# Example
|
31
32
|
# > get.(@env[:host], "/userinfo", {authorization: "Bearer <token> }, :url_encoded, {} )
|
32
33
|
def get
|
33
|
-
-> correlation, service, resource, hdrs, enc, query {
|
34
|
-
HttpPort.get.(correlation, service, resource, hdrs, enc, query)
|
34
|
+
-> correlation, service, resource, opts, hdrs, enc, query {
|
35
|
+
HttpPort.get.(correlation, service, resource, opts, hdrs, enc, query)
|
35
36
|
}.curry
|
36
37
|
end
|
37
38
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foucault_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Col Perks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stoplight
|