Make Web API response headers accessible
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with lib/slack/web/faraday/request.rb at the linked return statement, then read the issue discussion about exposing successful-response headers. A complete change would make headers accessible without polluting the response body, but the issue does not settle the API shape or name tests to run.
Written by the indexing model from the issue text.
Description
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:
https://github.com/slack-ruby/slack-ruby-client/blob/ebf98319cf9d89ad4e75dbca0ae8ecf94a855aa3/lib/slack/web/faraday/request.rb#L36
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 inSlack::Messages::Messageand 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
responseobject, giving access to the body as well as the headers (and much else). [body, response_headers]- etc.
- The entire raw
- Dominant language
- Ruby
- Stars
- 1.3k
- Forks
- 222
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from slack-ruby/slack-ruby-client
-
new feature question
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
slack-ruby/slack-ruby-client#586 · 3 comments ·
-
bug?
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
slack-ruby/slack-ruby-client#579 · 3 comments ·
-
new feature web api
Difficulty 3/5 1-2 days Newbie friendliness 42/100
slack-ruby/slack-ruby-client#482 · 5 comments ·
-
new feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
slack-ruby/slack-ruby-client#414 · 14 comments ·
-
confirmed bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
slack-ruby/slack-ruby-client#409 · 5 comments ·
All issues in slack-ruby/slack-ruby-client
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100