mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-06 00:03:36 -04:00
Updates README.md to clarify writing middleware
Clarify that the `on_complete` handler requires an argument to yield up the `response_env` if they would like to affect the response.
This commit is contained in:
parent
ac7cc3a7bf
commit
71973e57cc
@ -107,11 +107,13 @@ Middleware are classes that implement a `call` instance method. They hook into
|
|||||||
the request/response cycle.
|
the request/response cycle.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
def call(env)
|
def call(request_env)
|
||||||
# do something with the request
|
# do something with the request
|
||||||
|
# request_env[:request_headers].merge!(...)
|
||||||
|
|
||||||
@app.call(env).on_complete do
|
@app.call(request_env).on_complete do |response_env|
|
||||||
# do something with the response
|
# do something with the response
|
||||||
|
# response_env[:response_headers].merge!(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user