The response headers in Slack's Web API contain information that is sometimes useful. For example x-oauth-scopes is a list of scopes that the token has. This is the only way (that I know of) to check the scopes on an existing token through the API. My use case is I'd like to be able to use auth.test to check the scopes on a token via x-oauth-scopes.
The current implementation doesn't give a way to access the response headers on a successful request, since it returns only the body:
The headers are accessible on the error object raised on failed requests since the entire response object is on the error:
slack_error.response.headers
I'm trying to think how we could make the headers accessible on successful responses. Some bad ideas:
- Shove them into the body object under the key
response_headers. This object is then wrapped in Slack::Messages::Message and returned. I don't like this because it pollutes the body.
- An option that can be passed to any request (possibly also set on a client) that causes it to return something different:
- The entire raw
response object, giving access to the body as well as the headers (and much else).
[body, response_headers]
- etc.
The response headers in Slack's Web API contain information that is sometimes useful. For example
x-oauth-scopesis a list of scopes that the token has. This is the only way (that I know of) to check the scopes on an existing token through the API. My use case is I'd like to be able to useauth.testto check the scopes on a token viax-oauth-scopes.The current implementation doesn't give a way to access the response headers on a successful request, since it returns only the body:
slack-ruby-client/lib/slack/web/faraday/request.rb
Line 36 in ebf9831
The headers are accessible on the error object raised on failed requests since the entire response object is on the error:
I'm trying to think how we could make the headers accessible on successful responses. Some bad ideas:
response_headers. This object is then wrapped inSlack::Messages::Messageand returned. I don't like this because it pollutes the body.responseobject, giving access to the body as well as the headers (and much else).[body, response_headers]