Coder Social home page Coder Social logo

rootlyhq / faraday_middleware-aws-sigv4 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from winebarrel/faraday_middleware-aws-sigv4

0.0 0.0 0.0 67 KB

Faraday middleware for AWS Signature Version 4 using aws-sigv4.

License: MIT License

Ruby 100.00%

faraday_middleware-aws-sigv4's Introduction

FaradayMiddleware::AwsSigV4

Faraday middleware for AWS Signature Version 4 using aws-sigv4.

Gem Version Build Status Coverage Status

Required dependency version

version ruby faraday
>= 0.6.0 >= 2.4 >= 1.8
>= 0.5.0 >= 2.4 >= 0.15
>= 0.3.0 >= 2.3 >= 0.15
< 0.3.0 - < 0.15

Installation

Add this line to your application's Gemfile:

gem 'faraday_middleware-aws-sigv4'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faraday_middleware-aws-sigv4

Usage

# `gem install faraday_middleware` is required for this example.
# However, FaradayMiddleware::AwsSigV4 works without faraday_middleware.
require 'faraday_middleware/aws_sigv4'
require 'pp'

conn = Faraday.new(url: 'https://apigateway.us-east-1.amazonaws.com') do |faraday|
  faraday.request :aws_sigv4,
    service: 'apigateway',
    region: 'us-east-1',
    access_key_id: ENV['AWS_ACCESS_KEY_ID'],
    secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
  # see http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html

  faraday.response :json, content_type: /\bjson\b/

  # NOTE: If you need to send case sensitive headers like `x-amz-access-token` in `SP API`.
  # cf. https://github.com/lostisland/faraday/issues/747#issuecomment-439864181
  faraday.adapter Faraday.default_adapter
end

res = conn.get '/account'

pp res.body
#=> {"_links"=>
#     {"curies"=>
#       {"href"=>
#         "http://docs.aws.amazon.com/apigateway/latest/developerguide/account-apigateway-{rel}.html",
#        "name"=>"account",
#        "templated"=>true},
#      "self"=>{"href"=>"/account"},
#      "account:update"=>{"href"=>"/account"}},
#    "throttleSettings"=>{"rateLimit"=>10000.0, "burstLimit"=>5000}}

Upgrading from faraday_middleware-aws-signers-v4

If you previously provided the service_name option, you need to rename it service

Test

bundle install
bundle exec appraisal install
bundle exec appraisal faraday-1.8 rake

Related Links

faraday_middleware-aws-sigv4's People

Contributors

winebarrel avatar kwent avatar treacher avatar maschwenk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.