Skip to content

Instantly share code, notes, and snippets.

@tadyjp
Last active October 4, 2017 15:22
Show Gist options
  • Save tadyjp/c5afbd85fd00e6f91d3deba7c20a38c1 to your computer and use it in GitHub Desktop.
Save tadyjp/c5afbd85fd00e6f91d3deba7c20a38c1 to your computer and use it in GitHub Desktop.

Revisions

  1. tadyjp revised this gist Oct 4, 2017. No changes.
  2. tadyjp revised this gist Oct 4, 2017. No changes.
  3. tadyjp revised this gist Oct 4, 2017. No changes.
  4. tadyjp revised this gist Oct 4, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions file5.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    if Net::HTTP::HAVE_ZLIB
    env.request_headers['Accept-Encoding'] ||= 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
    end
  5. tadyjp revised this gist Oct 4, 2017. No changes.
  6. tadyjp revised this gist Oct 4, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions file4.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # This middleware is NOT necessary when these adapters are used:
    # - net_http on Ruby 1.9+
    # - net_http_persistent on Ruby 2.0+
    # - em_http
  7. tadyjp revised this gist Oct 4, 2017. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions file1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    elasticsearch (5.0.0)
    elasticsearch-api (5.0.0)
    elasticsearch-transport (5.0.0)
    elasticsearch-dsl (0.1.4)
    elasticsearch-model (0.1.9)
    elasticsearch-rails (0.1.9)
    elasticsearch-transport (5.0.0)
    faraday (0.9.2)
    faraday_middleware (0.12.2)
    faraday_middleware-aws-signers-v4 (0.1.5)

  8. tadyjp revised this gist Oct 4, 2017. No changes.
  9. tadyjp created this gist Oct 4, 2017.
    5 changes: 5 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@

    ...
    gem 'faraday_middleware'
    ...

    14 changes: 14 additions & 0 deletions aws.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@


    Elasticsearch::Model.client = Elasticsearch::Client.new(
    host: ENV.fetch('ELASTICSEARCH_ENDPOINT'),
    port: 80
    ) do |faraday|
    faraday.use FaradayMiddleware::Gzip # ここを追加
    faraday.request :aws_signers_v4,
    credentials: Aws::Credentials.new(ENV.fetch('AWS_KEY_ID'), ENV.fetch('AWS_ACCESS_KEY')),
    service_name: 'es',
    region: 'ap-northeast-1'
    faraday.adapter Faraday.default_adapter
    end

    1 change: 1 addition & 0 deletions file0.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    MultiJson::ParseError: unexpected character at line 1, column 1 [parse.c:664]