visionmedia / google-search

Ruby - Google Search API
263 stars 53 forks source link

How do you prefer to have proxy support? #2

Closed miguelff closed 8 years ago

miguelff commented 12 years ago

Hi TJ,

I've checked out your gem because I need to create a toy metasearch engine, the thing is that I need to have proxy support to pass through my university network, and I was about to create a patch.

As you already know, adding proxy support is trivial but, in order to keep the excellent usability of the API I was wondering which one of the following approaches would you prefer me to follow:

Google::Search::Web.new(:query => 'naked celebrities',  :proxy => 'http://proxy.uniovi.es:8888').each do |web_result|
   #... Whatever
 end
Google::Search::Defaults.set(:proxy, 'http://proxy.uniovi.es:8888')
Google::Search::Web.new(:query => 'naked celebrities').each{ | web_result | ... }
Google::Search::Images.new(:query => 'angelina jolie').each{ | image | ... }
Google::Search::Local.new(:query => 'foo bar').each{ |place| ... }

Both alternatives can be complementary.

Do you think that having a Defaults object would break your API orthogonality? having it would ease the case of needing a proxy, which IMHO is not that uncommon, but I would like to know your opinion.

Regards,

Miguel

sevk commented 8 years ago

I need proxy too , thank you .