Skip to content
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

Inherit custom headers #280

Merged
merged 1 commit into from
Apr 13, 2018
Merged

Inherit custom headers #280

merged 1 commit into from
Apr 13, 2018

Conversation

f-mer
Copy link
Contributor

@f-mer f-mer commented Dec 18, 2017

This PR resolves #255 by making custom_headers inherit from ancestors.

I think this should be the expected behaviour but sadly is not backwards compatible. Should be backwards compatible.
Would love to hear some feedback 😃

class ArticleResource < JsonApiClient::Resource
end

class ApplicationController
  around_action :configure_json_api_client

  def index
    # will request articles with the authorization header set
     articles = ArticleResource.all
  end

  private

  def configure_json_api_client
    JsonApiClient::Resource.with_headers(authorization: 'Bearer TOKEN') { yield }
  end
end

@jsmestad
Copy link
Collaborator

jsmestad commented Apr 3, 2018

100% yes!

@webandtech
Copy link
Collaborator

@chingor13 looks good to me and I don't see any backward compatibility issues. I am going to try to get my team more involved in helping this project. Let me know if I can help on the PRs.

@jsmestad
Copy link
Collaborator

For @f-mer and whomever else gets caught by this. I've pulled this into a released fork of this gem jsonapi-consumer along with some other outstanding bug fixes.

@mltsy
Copy link

mltsy commented Apr 13, 2018

I don't think this actually resolves #255 or its related issue #215 (maybe it resolves a different issue? See my comment on #255)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store connection in Thread local or instance instead of class
5 participants