Faraday: Faraday removes paths in base url

Created on 8 Aug 2013  ·  2Comments  ·  Source: lostisland/faraday

I'm having huge problems preserving the paths in my Faraday base url:

conn = Faraday.new(:url => 'http://example.com/api')
conn.get '/index' #=> GET http://example.com/index

Shouldn't this call http://example.com/api/index?

This article suggests so:
http://www.intridea.com/blog/2012/3/12/faraday-one-http-client-to-rule-them-all

Do I have to do anything to not let Faraday strip out the /api in my base url?

Also, I'm running Faraday 0.8.8 and Ruby 1.9.3p286. All docs say that Faraday shouldn't behave like this, but I'm seeing it on my mac, and on Linux virtual machines.

Most helpful comment

conn.get 'index'

(note the lack of leading slash)

If you use the leading slash, it means an absolute path, i.e. "discard whatever path is configured by the URL prefix of this connection".

All 2 comments

conn.get 'index'

(note the lack of leading slash)

If you use the leading slash, it means an absolute path, i.e. "discard whatever path is configured by the URL prefix of this connection".

Oh god, you're right. I was so sure I tried this a million times. Thanks a bunch.

Was this page helpful?
0 / 5 - 0 ratings