Skip to content

Most elegant and terse way of adding wrappers around the library #13

Closed Answered by HoneyryderChuck
forthrin asked this question in Q&A
Discussion options

You must be logged in to vote

The recommended way is building a custom plugin.

Intercepting a request can be done like this:

module MyCachePlugin
  module InstanceMethods
    def send_requests(*requests)
       cached_responses = get_cached_requests(requests)
       # and for the remainder, call super, and guarantee ordered responses based on requests input
    end
  end
end

You'll need to get familiar with httpx internal API, so I suggest reading the documentation, and studying other similar plugins, such as the response_cache plugin.

Inheritance is discouraged by the author (for unspecified reasons).

There's no documentation, nor wiki page, suggesting inheritance as a gateway to customize functionality. On the oth…

Replies: 7 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by HoneyryderChuck
Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Comment options

You must be logged in to vote
1 reply
@HoneyryderChuck
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants