From f4f1ba9ffd8bab67c29f0e43d0759536b670be35 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 28 Aug 2014 12:56:08 -0400 Subject: [PATCH] Follow redirects, fixes #58. --- CHANGELOG.md | 14 +++++++++----- lib/hyperclient/entry_point.rb | 1 + test/hyperclient/entry_point_test.rb | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f668dc..3ca5f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,17 @@ +== Next +* enhancements + * [#58](https://github.com/codegram/hyperclient/issues/58): Automatically follow redirects (by [@dblock](https://github.com/dblock)). + == 0.3.1 * backwards incompatible changes - * Nothing + * Nothing. * enhancements - * Support arrays of Links (by @rehevkor5) + * Support arrays of Links (by @rehevkor5). * Created the CHANGELOG. -* bug fix - * Nothing +* bug fixes + * Nothing. * deprecations - * Nothing + * Nothing. diff --git a/lib/hyperclient/entry_point.rb b/lib/hyperclient/entry_point.rb index cd58e90..79bf00f 100644 --- a/lib/hyperclient/entry_point.rb +++ b/lib/hyperclient/entry_point.rb @@ -42,6 +42,7 @@ def connection # Returns a block. def default_faraday_block lambda do |faraday| + faraday.use FaradayMiddleware::FollowRedirects faraday.request :json faraday.response :json, content_type: /\bjson$/ faraday.adapter :net_http diff --git a/test/hyperclient/entry_point_test.rb b/test/hyperclient/entry_point_test.rb index 832328e..670a2e5 100644 --- a/test/hyperclient/entry_point_test.rb +++ b/test/hyperclient/entry_point_test.rb @@ -19,6 +19,7 @@ module Hyperclient it 'creates a Faraday connection with the default block' do handlers = entry_point.connection.builder.handlers + handlers.must_include FaradayMiddleware::FollowRedirects handlers.must_include FaradayMiddleware::EncodeJson handlers.must_include FaradayMiddleware::ParseJson handlers.must_include Faraday::Adapter::NetHttp @@ -31,4 +32,4 @@ module Hyperclient end end end -end \ No newline at end of file +end