Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing leading slash of Example #976

Closed
mom0tomo opened this issue May 10, 2019 · 2 comments · Fixed by #977
Closed

Removing leading slash of Example #976

mom0tomo opened this issue May 10, 2019 · 2 comments · Fixed by #977

Comments

@mom0tomo
Copy link

mom0tomo commented May 10, 2019

Basic Info

  • Faraday Version: 0.15.4
  • Ruby Version: ruby 2.6.1p33

Issue description

I started using Faraday and got a problem that is same as #293
I just used the example in README, and found there is a leading slash.

I hope other beginners do not make the same mistake again.

Steps to reproduce

README.md

47 ```ruby
48 conn = Faraday.new(:url => 'http://www.example.com')
- 49 response = conn.get '/users'                 # GET http://www.example.com/users'
+ 49 response = conn.get 'users'                 # GET http://www.example.com/users'
50 ```
@iMacTia
Copy link
Member

iMacTia commented May 10, 2019

Hi @mom0tomo thanks for raising this again, I know it has been a painful discovery for many developers over the past and I agree with you this should be explained in a better way in the README.
However, I don't think just removing the leading slash from the example is going to help everyone, and may confuse others that need to use an absolute path for particular requests.

What do you think about changing the connection initial url into http://www.example.com/api instead and providing 2 example:

  1. response = conn.get 'users' showing that this keeps the /api path provided to the connection
  2. response = conn.get '/users' showing that this removes the /api path from the request

I think this way we can make this point clear for everyone

@mom0tomo
Copy link
Author

Hi @iMacTia, I think it's a very good idea!
I would be glad if you would change README so, and everyone will surely be very happy.

iMacTia added a commit that referenced this issue May 11, 2019
Updates the REAME to explain how the absolute path overrides the one provided while initialising the connection.
Fixes #976
iMacTia added a commit that referenced this issue May 12, 2019
Updates the REAME to explain how the absolute path overrides the one provided while initialising the connection.
Fixes #976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants