Class: Rafaday::BodySigningMiddleware
- Inherits:
-
Object
- Object
- Rafaday::BodySigningMiddleware
- Defined in:
- lib/rafaday/body_signing_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ BodySigningMiddleware
constructor
A new instance of BodySigningMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ BodySigningMiddleware
Returns a new instance of BodySigningMiddleware.
7 8 9 10 11 |
# File 'lib/rafaday/body_signing_middleware.rb', line 7 def initialize(app, ={}) @app = app @secret = .fetch(:secret) { '' } @digest = .fetch(:digest) { 'sha1' } end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rafaday/body_signing_middleware.rb', line 13 def call(env) if env[:body] digest = OpenSSL::HMAC.new @secret, @digest digest << env[:body].to_s url = env[:url] query = url.query_values || {} url.query_values = query.merge :sig => digest.to_s end @app.call env end |