https://github.com/dmarkow/faraday_yaml
YAML Response/Request Middleware for Faraday
https://github.com/dmarkow/faraday_yaml
Last synced: 11 months ago
JSON representation
YAML Response/Request Middleware for Faraday
- Host: GitHub
- URL: https://github.com/dmarkow/faraday_yaml
- Owner: dmarkow
- Archived: true
- Created: 2011-02-04T21:47:36.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-05-10T15:56:55.000Z (about 15 years ago)
- Last Synced: 2024-10-31T05:52:01.484Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Faraday YAML Middleware
Yeah, JSON is at least 2.9x cooler than YAML, but sometimes you're stuck using it, right?
## Installation
gem install faraday_yaml
### Examples
Github's YAML API is currently deprecated; it works for the response example, but not for the request example.
#### Response
conn = Faraday::Connection.new(:url => "http://github.com") do |builder|
builder.adapter Faraday.default_adapter
builder.use Faraday::Response::YAML
end
resp = conn.get do |req|
req.url "/api/v2/yaml/user/show/dmarkow"
end
u = resp.body
u['user']['name']
# => "Dylan Markow"
#### Request
conn = Faraday::Connection.new(:url => "http://USERNAME:PASSWORD@github.com") do |builder|
builder.adapter Faraday.default_adapter
builder.use Faraday::Request::YAML
builder.use Faraday::Response::YAML
end
resp = conn.post do |req|
req.url "/api/v2/yaml/user/show/dmarkow"
req.body = {
"values" => {
"location" => "Portland, OR"
}
}
end
u = resp.body
u['user']['location']
# => "Portland, OR"