mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-04 00:02:03 -04:00
Merge branch 'faraday-website' of https://github.com/lostisland/faraday into faraday-website
This commit is contained in:
commit
5d3e667c1a
@ -3,12 +3,8 @@ layout: documentation
|
||||
title: "EM-HTTP Adapter"
|
||||
permalink: /adapters/em-http
|
||||
hide: true
|
||||
prev_name: Patron Adapter
|
||||
prev_link: ./patron
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
next_name: HTTPClient Adapter
|
||||
next_link: ./httpclient
|
||||
---
|
||||
|
||||
This Adapter uses the [em-http-request][rdoc] gem to make HTTP requests.
|
||||
|
@ -3,12 +3,8 @@ layout: documentation
|
||||
title: "EM-Synchrony Adapter"
|
||||
permalink: /adapters/em-synchrony
|
||||
hide: true
|
||||
prev_name: Patron Adapter
|
||||
prev_link: ./patron
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
next_name: HTTPClient Adapter
|
||||
next_link: ./httpclient
|
||||
---
|
||||
|
||||
This Adapter uses the [em-synchrony][rdoc] gem to make HTTP requests.
|
||||
|
@ -3,12 +3,8 @@ layout: documentation
|
||||
title: "Excon Adapter"
|
||||
permalink: /adapters/excon
|
||||
hide: true
|
||||
prev_name: Net::HTTP::Persistent Adapter
|
||||
prev_link: ./net-http-persistent
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
next_name: Patron Adapter
|
||||
next_link: ./patron
|
||||
---
|
||||
|
||||
This Adapter uses the [excon][rdoc] gem to make HTTP requests.
|
||||
|
@ -3,9 +3,7 @@ layout: documentation
|
||||
title: "HTTPClient Adapter"
|
||||
permalink: /adapters/httpclient
|
||||
hide: true
|
||||
prev_name: EM-Synchrony Adapter
|
||||
prev_link: ./em-synchrony
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
---
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
---
|
||||
layout: page
|
||||
layout: documentation
|
||||
title: "Adapters"
|
||||
permalink: /adapters
|
||||
---
|
||||
|
||||
Adapters are what performs the HTTP Request in the background.
|
||||
They receive a `Faraday::Request` and make the actual call, returning a `Faraday::Response`.
|
||||
Faraday allows you to change the adapter at any time through the configuration block.
|
||||
The Faraday Adapter interface determines how a Faraday request is turned into
|
||||
a Faraday response object. Adapters are typically implemented with common Ruby
|
||||
HTTP clients, but can have custom implementations. Adapters can be configured
|
||||
either globally or per Faraday Connection through the configuration block.
|
||||
|
||||
{: .mt-60}
|
||||
## Supported adapters
|
||||
## Built-in adapters
|
||||
|
||||
Faraday supports these adapters out of the box:
|
||||
Faraday includes these adapters (but not the HTTP client libraries):
|
||||
|
||||
* [Net::HTTP][net_http] _(this is the default adapter)_
|
||||
* [Net::HTTP::Persistent][persistent]
|
||||
@ -20,16 +21,20 @@ Faraday supports these adapters out of the box:
|
||||
* [EM-Synchrony][em-synchrony]
|
||||
* [HTTPClient][httpclient]
|
||||
|
||||
While most adapters use a common Ruby HTTP client library, adapters can also
|
||||
have completely custom impelmentations.
|
||||
|
||||
* [Test Adapter][testing]
|
||||
* Rack Adapter (link TBD)
|
||||
|
||||
## External adapters
|
||||
|
||||
Adapters are slowly being moved into their own gems, or bundled with HTTP clients.
|
||||
Please refer to their documentation for usage examples.
|
||||
Here is the list of known external adapters:
|
||||
|
||||
* [Typhoeus][typhoeus]
|
||||
* [HTTP.rb][faraday-http]
|
||||
|
||||
Faraday also includes a Rack adapter for hitting loaded Rack applications through
|
||||
Rack::Test, and a [Test adapter][testing] for stubbing requests by hand.
|
||||
|
||||
## Ad-hoc adapters customization
|
||||
|
||||
Faraday is intended to be a generic interface between your code and the adapter.
|
||||
@ -45,4 +50,4 @@ The block parameter will change based on the adapter you're using. See each adap
|
||||
[httpclient]: ./httpclient
|
||||
[typhoeus]: https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/adapters/faraday.rb
|
||||
[faraday-http]: https://github.com/lostisland/faraday-http
|
||||
[testing]: ../testing
|
||||
[testing]: ./testing
|
||||
|
@ -3,9 +3,7 @@ layout: documentation
|
||||
title: "Net::HTTP Adapter"
|
||||
permalink: /adapters/net-http
|
||||
hide: true
|
||||
next_name: Net::HTTP::Persistent Adapter
|
||||
next_link: ./net-http-persistent
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
---
|
||||
|
||||
|
@ -3,12 +3,8 @@ layout: documentation
|
||||
title: "Net::HTTP::Persistent Adapter"
|
||||
permalink: /adapters/net-http-persistent
|
||||
hide: true
|
||||
prev_name: Net::HTTP Adapter
|
||||
prev_link: ./net-http
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
next_name: Excon Adapter
|
||||
next_link: ./excon
|
||||
---
|
||||
|
||||
This Adapter uses the [net-http-persistent][rdoc] gem to make HTTP requests.
|
||||
|
@ -3,12 +3,8 @@ layout: documentation
|
||||
title: "Patron Adapter"
|
||||
permalink: /adapters/patron
|
||||
hide: true
|
||||
prev_name: Excon Adapter
|
||||
prev_link: ./excon
|
||||
top_name: Back to Adapters
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
next_name: EM-Synchrony Adapter
|
||||
next_link: ./em-synchrony
|
||||
---
|
||||
|
||||
This Adapter uses the [patron][rdoc] gem to make HTTP requests.
|
||||
|
@ -1,8 +1,10 @@
|
||||
---
|
||||
layout: page
|
||||
layout: documentation
|
||||
title: "Testing"
|
||||
permalink: /testing
|
||||
permalink: /adapters/testing
|
||||
hide: true
|
||||
top_name: Adapters
|
||||
top_link: ./
|
||||
---
|
||||
|
||||
The built-in Faraday Test adapter lets you define stubbed HTTP requests. This can
|
@ -41,28 +41,11 @@ You can also install the [`faraday_middleware`][faraday_middleware]
|
||||
extension gem to access a collection of useful Faraday middleware.
|
||||
|
||||
{: .mt-60}
|
||||
## Usage
|
||||
|
||||
* [Introduction][intro]
|
||||
* [Customizing the Request][customize]
|
||||
* [Streaming Responses][streaming]
|
||||
* [Middleware][middleware]
|
||||
* [Available Middleware][list]
|
||||
* [Writing Middleware][custom]
|
||||
* [Adapters][adapters]
|
||||
* [Testing][testing]
|
||||
* [Team][team]
|
||||
* [Faraday API RubyDoc](http://www.rubydoc.info/gems/faraday)
|
||||
{: .text-center}
|
||||
[<i class="fas fa-fw fa-book-open"> </i> Read the docs][usage]{: .btn}
|
||||
|
||||
[github]: https://github.com/lostisland/faraday
|
||||
[gitter]: https://gitter.im/lostisland/faraday
|
||||
[faraday_middleware]: https://github.com/lostisland/faraday_middleware
|
||||
[intro]: ./introduction
|
||||
[customize]: ./introduction/customize
|
||||
[streaming]: ./introduction/streaming
|
||||
[middleware]: ./middleware
|
||||
[list]: ./middleware/list
|
||||
[custom]: ./middleware/custom
|
||||
[adapters]: ./adapters
|
||||
[testing]: ./testing
|
||||
[team]: ./team
|
||||
[usage]: ./usage
|
||||
|
@ -3,6 +3,8 @@ layout: documentation
|
||||
title: "Writing Middleware"
|
||||
permalink: /middleware/custom
|
||||
hide: true
|
||||
top_name: Middleware
|
||||
top_link: ./
|
||||
prev_name: Available Middleware
|
||||
prev_link: ./list
|
||||
---
|
||||
|
@ -3,8 +3,8 @@ layout: documentation
|
||||
title: "Available Middleware"
|
||||
permalink: /middleware/list
|
||||
hide: true
|
||||
prev_name: Middleware Introduction
|
||||
prev_link: ./
|
||||
top_name: Middleware
|
||||
top_link: ./
|
||||
next_name: Writing Middleware
|
||||
next_link: ./custom
|
||||
---
|
||||
|
@ -39,4 +39,4 @@ conn.post('/', { a: [1, 3], b: { c: 2, d: 4} })
|
||||
# Body: a%5B%5D=1&a%5B%5D=3&b%5Bc%5D=2&b%5Bd%5D=4
|
||||
```
|
||||
|
||||
[customize]: ../introduction/customize/#changing-how-parameters-are-serialized
|
||||
[customize]: ../usage/customize/#changing-how-parameters-are-serialized
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
layout: documentation
|
||||
title: "Customizing the Request"
|
||||
permalink: /introduction/customize
|
||||
permalink: /usage/customize
|
||||
hide: true
|
||||
prev_name: Introduction
|
||||
prev_link: ./
|
||||
top_name: Usage
|
||||
top_link: ./
|
||||
next_name: Streaming Responses
|
||||
next_link: ./streaming
|
||||
---
|
||||
@ -14,7 +14,7 @@ Configuration can be set up with the connection and/or adjusted per request.
|
||||
As connection options:
|
||||
|
||||
```ruby
|
||||
conn = Faraday.new('http://sushi.com', request: { timeout: 5 })
|
||||
conn = Faraday.new('http://sushi.com', request: { timeout: 5 })
|
||||
conn.get('/search')
|
||||
```
|
||||
|
||||
@ -93,4 +93,4 @@ You can also specify a custom proxy when initializing the connection:
|
||||
conn = Faraday.new('http://www.example.com', proxy: 'http://proxy.com')
|
||||
```
|
||||
|
||||
[ruby-find-proxy]: https://ruby-doc.org/stdlib-2.6.3/libdoc/uri/rdoc/URI/Generic.html#method-i-find_proxy
|
||||
[ruby-find-proxy]: https://ruby-doc.org/stdlib-2.6.3/libdoc/uri/rdoc/URI/Generic.html#method-i-find_proxy
|
@ -1,13 +1,11 @@
|
||||
---
|
||||
layout: documentation
|
||||
title: "Introduction"
|
||||
permalink: /introduction
|
||||
title: "Usage"
|
||||
permalink: /usage
|
||||
next_name: Customizing the Request
|
||||
next_link: ./customize
|
||||
---
|
||||
|
||||
## Faraday Basics
|
||||
|
||||
Make a simple `GET` request by requiring the Faraday gem and using `Faraday.get`:
|
||||
|
||||
```ruby
|
@ -1,8 +1,10 @@
|
||||
---
|
||||
layout: documentation
|
||||
title: "Streaming Responses"
|
||||
permalink: /introduction/streaming
|
||||
permalink: /usage/streaming
|
||||
hide: true
|
||||
top_name: Usage
|
||||
top_link: ./
|
||||
prev_name: Customizing the Request
|
||||
prev_link: ./customize
|
||||
---
|
||||
@ -28,7 +30,7 @@ conn.get('/nigiri/sake.json') do |req|
|
||||
end
|
||||
end
|
||||
|
||||
# Joins all response chunks together
|
||||
# Joins all response chunks together
|
||||
streamed.join
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user