Class: SearchFlip::AwsSigv4Plugin
- Inherits:
-
Object
- Object
- SearchFlip::AwsSigv4Plugin
- Defined in:
- lib/search_flip/aws_sigv4_plugin.rb
Overview
The SearchFlip::AwsSigV4Plugin is a plugin for the SearchFlip::HTTPClient to be used with AWS Elasticsearch to sign requests, i.e. add signed headers, before sending the request to Elasticsearch.
Instance Attribute Summary collapse
-
#signer ⇒ Object
Returns the value of attribute signer.
Instance Method Summary collapse
- #call(request, method, uri, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ AwsSigv4Plugin
constructor
A new instance of AwsSigv4Plugin.
Constructor Details
#initialize(options = {}) ⇒ AwsSigv4Plugin
Returns a new instance of AwsSigv4Plugin.
26 27 28 |
# File 'lib/search_flip/aws_sigv4_plugin.rb', line 26 def initialize( = {}) self.signer = Aws::Sigv4::Signer.new({ service: "es" }.merge()) end |
Instance Attribute Details
#signer ⇒ Object
Returns the value of attribute signer.
24 25 26 |
# File 'lib/search_flip/aws_sigv4_plugin.rb', line 24 def signer @signer end |
Instance Method Details
#call(request, method, uri, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/search_flip/aws_sigv4_plugin.rb', line 30 def call(request, method, uri, = {}) full_uri = URI.parse(uri) full_uri.query = URI.encode_www_form([:params]) if [:params] signature_request = { http_method: method.to_s.upcase, url: full_uri.to_s } signature_request[:body] = [:body] if .key?(:body) signature = signer.sign_request(signature_request) request.headers(signature.headers) end |