mwunsch / weary

A framework and DSL for building RESTful web service clients
MIT License
480 stars 23 forks source link

Port numbers in URL #6

Closed joelmoss closed 12 years ago

joelmoss commented 12 years ago

When specifying the port number in the domain or path (http://localhost:9200), Weary is treating it as a URL variable, which is not correct. Not sure how best to handle this, but it's a definate blocker. for me, and I am sure for a lot of others.

Perhaps Weary::Client.domain should accept an option that tells Weary to ignore colon prefixed URL variables, like this:

module Gitchen
  class Search < Weary::Client
    domain 'http://localhost:9200', :ignore_colons => true
  end
end

I would be happy to implement this. Thoughts?

mwunsch commented 12 years ago

I'm not a big fan of this approach ie adding options params. Especially if there's only one valid option in the hash. I think it'd be better to update the regex of the domain method (https://github.com/mwunsch/weary/blob/master/lib/weary/resource.rb#L25):

@uri = Addressable::Template.new(uri.gsub(/:(\w+)/) { "{#{$1}}" }) unless uri.nil?

to a pattern that match the word after a colon only if it does not begin with a digit.