faraday_middleware-escher 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/faraday/middleware/escher/base.rb +1 -2
- data/lib/faraday/middleware/escher/request_signer.rb +2 -2
- data/prototype/client.rb +9 -10
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a984251339554ffac17114badfddbf2869e994fe
|
4
|
+
data.tar.gz: 58ca6add13f632b99fda8b4d9e8febb2e2c9cf8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a240965032572dbc19685539f129b72b6109db206eba4dc38dc66ca8159858cad82102b6a79625c95cf89d729789c2ceb107c2fcb0cc06ef732f6f1c235e4ec
|
7
|
+
data.tar.gz: 593dbb569141fd10b2d66b1b516734f0af9bb96f40d6cd8bf58b5140cf48b53ef1c8c566c62ec7295c3b49b2a8feff4837c68e65c9bcf6be4d057e53dbef67ec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'socket'
|
2
1
|
require 'faraday/middleware/escher'
|
3
2
|
class Faraday::Middleware::Escher::Base < Faraday::Middleware
|
4
3
|
|
5
4
|
def initialize(app,options={})
|
6
5
|
|
7
6
|
super(app)
|
8
|
-
@host = options[:host]
|
7
|
+
@host = options[:host]
|
9
8
|
|
10
9
|
@escher_options = options[:options] || {}
|
11
10
|
@escher_credential_scope = options[:credential_scope] || raise(ArgumentError,'missing escher credential scope!')
|
@@ -20,12 +20,12 @@ class Faraday::Middleware::Escher::RequestSigner < Faraday::Middleware::Escher::
|
|
20
20
|
endpoint_with_query = [endpoint,env[:url].query].join('?')
|
21
21
|
|
22
22
|
request_headers = Hash[env[:request_headers].map{|k,v| [k,v] }]
|
23
|
-
request_headers['host'] ||= @host
|
23
|
+
request_headers['host'] ||= @host || env[:url].host
|
24
24
|
|
25
25
|
request_data = {
|
26
26
|
uri: endpoint_with_query,
|
27
27
|
method: env[:method].to_s.upcase,
|
28
|
-
headers: request_headers.to_a
|
28
|
+
headers: request_headers.to_a
|
29
29
|
}
|
30
30
|
|
31
31
|
request_data[:body]= env[:body] unless env[:body].nil?
|
data/prototype/client.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.absolute_path(File.join(__dir__, '..', 'lib')))
|
2
2
|
|
3
3
|
require_relative 'credentials'
|
4
|
+
require 'faraday_middleware/escher'
|
4
5
|
|
5
|
-
|
6
|
+
conn = Faraday.new(url: 'http://localhost:9292') do |builder|
|
6
7
|
|
7
|
-
|
8
|
+
builder.use FaradayMiddleware::Escher::RequestSigner,
|
9
|
+
credential_scope: CredentialScope,
|
10
|
+
options: AuthOptions,
|
11
|
+
active_key: -> { Escher::Keypool.new.get_active_key('EscherExample') }
|
8
12
|
|
9
|
-
|
10
|
-
credential_scope: CredentialScope,
|
11
|
-
options: AuthOptions,
|
12
|
-
active_key: -> { Escher::Keypool.new.get_active_key('EscherExample') }
|
13
|
+
builder.adapter :net_http
|
13
14
|
|
14
|
-
builder.adapter :net_http
|
15
15
|
|
16
|
-
|
17
|
-
end
|
16
|
+
end
|
18
17
|
|
19
18
|
# builder.use FaradayMiddleware::Escher::ResponseValidator,
|
20
19
|
# credential_scope: CredentialScope,
|
@@ -25,7 +24,7 @@ require 'json'
|
|
25
24
|
|
26
25
|
puts "\nResponse:",
|
27
26
|
conn.get { |r|
|
28
|
-
r.url('
|
27
|
+
r.url('/')
|
29
28
|
r.body='{ "name": "Unagi" }'
|
30
29
|
r.headers['X-Origin'] = JSON.generate(sender: 'cat', host: 'suite42')
|
31
30
|
r.params['kutya1']= 'cica1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday_middleware-escher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -190,3 +190,4 @@ test_files:
|
|
190
190
|
- spec/escher/base_spec.rb
|
191
191
|
- spec/escher/request_signer_spec.rb
|
192
192
|
- spec/spec_helper.rb
|
193
|
+
has_rdoc:
|