I want to change query params before request is hit using typhoeus. What should be right approach? Do we have interceptors in Ruby as that of Java, should I be using something like before_filter as that in Rails or meta-programming in Ruby? I just checked there is Typhoeus::Request::Before module to hook request. Can anyone help me out how can I implement it?
I have implemented typhoeus before to change query params just before request gets executed as below. Hope it helps someone.
require 'uri'
Typhoeus.before { |request|
uri = URI.parse(request.base_url)
uri.query = [uri.query, "param1=value1"].compact.join('&')
request.base_url = uri.to_s
request
}