Update docs to use httpbingo on example requests and add webrick for ruby 3.x support (#1383)

This commit is contained in:
José Augusto 2022-01-18 07:44:16 -03:00 committed by GitHub
parent ae55a744d1
commit 9f80f875f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -32,3 +32,6 @@ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
# Performance-booster for watching directories on Windows
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
# Ruby 3.X doesn't come with webrick by default anymore
gem 'webrick', '~> 1.7'

View File

@ -14,15 +14,15 @@ 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.get('/search')
conn = Faraday.new('http://httpbingo.org', request: { timeout: 5 })
conn.get('/ip')
```
Or as per-request options:
```ruby
conn.get do |req|
req.url '/search'
req.url '/ip'
req.options.timeout = 5
end
```
@ -32,7 +32,7 @@ This will be available in the `env` on all middleware.
```ruby
conn.get do |req|
req.url '/search'
req.url '/get'
req.options.context = {
foo: 'foo',
bar: 'bar'

View File

@ -21,7 +21,7 @@ This example implements such a callback:
# A buffer to store the streamed data
streamed = []
conn.get('/nigiri/sake.json') do |req|
conn.get('/stream/10') do |req|
# Set a callback which will receive tuples of chunk Strings
# and the sum of characters received so far
req.options.on_data = Proc.new do |chunk, overall_received_bytes|