-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Web API response headers accessible #378
Comments
@dblock any ideas? |
|
I see what you mean on #379 about option (2)(i) being bad from an API standpoint. Options 3-5 are less convenient, but since this is likely a rare use case that's OK with me. In my case I need to do this in only 1 spot at the moment. I guess my leaning is option 5. |
Want to try to implement 5? |
Thinking about this more, maybe we should (also) add |
The middleware is an interesting idea. Are you thinking it would store them on the instance of the client? |
Yep. |
I'm taking a crack at the middleware approach now. Do you think it should be optional via a new web config setting/attribute? |
Only if it creates significant overhead. Without looking at the code, I would try and enable that by default. |
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 useauth.test
to 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::Message
and returned. I don't like this because it pollutes the body.response
object, giving access to the body as well as the headers (and much else).[body, response_headers]
The text was updated successfully, but these errors were encountered: