Class: Binance::Client::REST_FUTURE::SignRequestMiddleware

Inherits:
Struct
  • Object
show all
Defined in:
lib/binance/client/rest/sign_request_middleware.rb

Overview

Sign the query string using HMAC(sha-256) and appends to query string

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



19
20
21
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 19

def app
  @app
end

#secret_keyObject

Returns the value of attribute secret_key

Returns:

  • (Object)

    the current value of secret_key



19
20
21
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 19

def secret_key
  @secret_key
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 20

def call(env)
    hash = OpenSSL::HMAC.hexdigest(
        OpenSSL::Digest.new('sha256'), secret_key, env.url.query
    )
    env.url.query = REST_FUTURE.add_query_param(env.url.query, 'signature', hash)

    app.call env
end