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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b617defc8bb9224584ac172ac307574da0cc2390
4
- data.tar.gz: c14eded164c5a69cdf5bc130ae7178e89411e9db
3
+ metadata.gz: a984251339554ffac17114badfddbf2869e994fe
4
+ data.tar.gz: 58ca6add13f632b99fda8b4d9e8febb2e2c9cf8a
5
5
  SHA512:
6
- metadata.gz: 42d68d65e8f07781d2263d4a360f18cea044388638ed0f8bdf83dec694366afb7ec604f7a22ab10c297a48bff1cd34d2b512508e1eebf021b5df5c194b17f17d
7
- data.tar.gz: 150ae63241bd1dcecd5854f4cf55df4e659b0318a4569450eab097a4c9882f92cef9e1132066b3e62fc80f42ab1a5962e9f3101f7aa12e5e6b99edeeb2667f5a
6
+ metadata.gz: 5a240965032572dbc19685539f129b72b6109db206eba4dc38dc66ca8159858cad82102b6a79625c95cf89d729789c2ceb107c2fcb0cc06ef732f6f1c235e4ec
7
+ data.tar.gz: 593dbb569141fd10b2d66b1b516734f0af9bb96f40d6cd8bf58b5140cf48b53ef1c8c566c62ec7295c3b49b2a8feff4837c68e65c9bcf6be4d057e53dbef67ec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
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] || Socket.gethostname
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 # env[:request_headers].map{|k,v| [k,v] }.push(['host',@host])
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
- require 'faraday_middleware/escher'
6
+ conn = Faraday.new(url: 'http://localhost:9292') do |builder|
6
7
 
7
- conn = Faraday.new do |builder|
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
- builder.use FaradayMiddleware::Escher::RequestSigner,
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('http://localhost:9292')
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.2
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: