Sha256: 185364ab473d158df6b4e29352d412d7d15abf82ec1edef194589e01177e2c39
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'api_signature' module ApiProxy class RequestOptionsBuilder attr_reader :env, :config delegate :api_key, :api_secret, :api_host, :api_port, :api_prefix, :url_scheme, :request_starts_with, to: :config def initialize(env, config) @env = env @config = config end def options { headers: signature_builder.headers, format: :json } end def url URI::Generic.build(scheme: url_scheme, host: api_host, port: api_port, path: path) end def request_method env['REQUEST_METHOD'].to_s.downcase end private def signature_builder @signature_builder ||= ApiSignature::Builder.new(request_params) end def request_params { access_key: api_key, secret: api_secret, request_method: request_method, scheme: url_scheme, host: api_host, port: api_port, path: path } end def path request_path = env['REQUEST_PATH'].gsub(request_starts_with, '') File.join(api_prefix, request_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
api_proxy-0.1.1 | lib/api_proxy/request_options_builder.rb |
api_proxy-0.1.0 | lib/api_proxy/request_options_builder.rb |