Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Access Faraday environment using #[] (#138)
Browse files Browse the repository at this point in the history
We're seeing `env` come through as a `Hash` rather than a
`Faraday::Response` here. Faraday's middleware docs are poor, but it
seems common to look up environment values using `[]` rather than
relying on the methods of `Response`, presumably because this can
happen.
  • Loading branch information
oggy authored and Chance Feick committed Apr 10, 2017
1 parent 7515b88 commit ed7df5a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/librato/metrics/middleware/expects_status.rb
Expand Up @@ -24,12 +24,12 @@ def on_complete(env)

def sanitize_request(env)
{
status: env.status,
url: env.url.to_s,
user_agent: env.request_headers["User-Agent"],
status: env[:status],
url: env[:url].to_s,
user_agent: (env[:request_headers] || {})["User-Agent"],
request_body: env[:request_body],
response_headers: env.response_headers,
response_body: env.body
response_headers: env[:response_headers],
response_body: env[:body]
}
end
end
Expand Down

0 comments on commit ed7df5a

Please sign in to comment.