faraday_json 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -0
- data/lib/faraday_json/encode_json.rb +1 -1
- data/lib/faraday_json/version.rb +1 -1
- data/lib/faraday_json.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c77a32170d967ebaa3950cda3adda8697a1408e1
|
4
|
+
data.tar.gz: 229a0bd27bc9a29873ecc20e80e24d67835cdaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1d60bda56f2465d32d22a8be678b691b11e8401f7d7deb791da725efb5fa1938667eaf2bd5348ee28c3abc9b1ddd4d66689dcdb44e577484189f464fd35566
|
7
|
+
data.tar.gz: 22b9691239581d61629c4a263960f4f24370d9ad2fadc4b059b17a7812a8a47429ca1fe9ef67c8fac7bd61eb2218158533d1d6730171b0b7c49fe9c74ee2a059
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Introduction
|
2
2
|
This is a character encoding-aware JSON middleware for Faraday.
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/faraday_json.svg)](http://badge.fury.io/rb/faraday_json)
|
4
5
|
[![Build Status](https://travis-ci.org/spriteCloud/faraday_json.svg)](https://travis-ci.org/spriteCloud/faraday_json)
|
5
6
|
|
6
7
|
The default JSON middleware from lostisland/faraday_middleware is not character
|
@@ -28,3 +29,38 @@ This middleware fixes these issues rather brute-force by:
|
|
28
29
|
When no charset is provided, all bets are off. The correct default would be to
|
29
30
|
assume US-ASCII, but that may break some code. This middleware lets you override
|
30
31
|
this default.
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
Add this line to your application's Gemfile:
|
36
|
+
|
37
|
+
gem 'faraday_json'
|
38
|
+
|
39
|
+
And then execute:
|
40
|
+
|
41
|
+
$ bundle
|
42
|
+
|
43
|
+
Or install it yourself as:
|
44
|
+
|
45
|
+
$ gem install faraday_json
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
require 'faraday'
|
51
|
+
require 'faraday_middleware' # optional
|
52
|
+
require 'faraday_json' # replaces JSON handling from previous require
|
53
|
+
|
54
|
+
client = Faraday.new('http://some_url') do |conn|
|
55
|
+
conn.request :json
|
56
|
+
conn.response :json
|
57
|
+
|
58
|
+
conn.adapter Faraday.default_adapter
|
59
|
+
end
|
60
|
+
|
61
|
+
client.post '/', :a => "röck döts"
|
62
|
+
```
|
63
|
+
|
64
|
+
1. `faraday_middleware` is not required for JSON handling.
|
65
|
+
1. Require `faraday_json` *after* `faraday_middleware` to override the behaviour
|
66
|
+
from `faraday_middleware`.
|
@@ -60,7 +60,7 @@ module FaradayJSON
|
|
60
60
|
|
61
61
|
# We'll add a content length, because otherwise we're relying on every
|
62
62
|
# component down the line properly interpreting UTF-8 - that can fail.
|
63
|
-
env[:request_headers][CONTENT_LENGTH] ||= env[:body].bytesize
|
63
|
+
env[:request_headers][CONTENT_LENGTH] ||= env[:body].bytesize.to_s
|
64
64
|
|
65
65
|
# Always base the encoding we're sending in the content type header on
|
66
66
|
# the string encoding.
|
data/lib/faraday_json/version.rb
CHANGED
data/lib/faraday_json.rb
CHANGED