Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Makes response JSON parsing use MultiJson

  • Loading branch information...
commit 9cfb5aca1c50774ee4423bbddf604ffa5ab8e77f 1 parent f937ea4
@vesan authored
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/kippt/connection.rb
View
13 lib/kippt/connection.rb
@@ -1,6 +1,17 @@
require "multi_json"
+require "faraday_middleware/response_middleware"
module Kippt::Connection
+ class ParseMultiJson < FaradayMiddleware::ResponseMiddleware
+ define_parser do |body|
+ begin
+ MultiJson.load(body) unless body.strip.empty?
+ rescue MultiJson::DecodeError
+ nil
+ end
+ end
+ end
+
def get(url, options = {})
request(:get, url, options)
end
@@ -21,7 +32,7 @@ def delete(url, options = {})
def connection
@connection ||= Faraday.new("https://kippt.com/api") do |builder|
- builder.use FaradayMiddleware::ParseJson
+ builder.use Kippt::Connection::ParseMultiJson
# builder.use Faraday::Response::Logger
builder.adapter Faraday.default_adapter
end
Please sign in to comment.
Something went wrong with that request. Please try again.