-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
request.url does not seem to include the prefix or version #174
Comments
If I remove the version and prefix, and mount the API at "/api" rather than at "/", |
I can confirm this is a bug. We should probably fix it, but I am not sure how (spec/grape/endpoint.spec). context 'request' do
it 'should be set to the url requested' do
subject.get('/url') do
request.url
end
get '/url'
last_response.body.should == "http://example.org/url"
end
it 'should include version' do
subject.version 'v1', :using => :path
subject.get('/url') do
request.url
end
get '/v1/url'
last_response.body.should == "http://example.org/v1/url"
end
it 'should include prefix' do
subject.version 'v1', :using => :path
subject.prefix 'api'
subject.get('/url') do
request.url
end
get '/api/v1/url'
last_response.body.should == "http://example.org/api/v1/url"
end
end The request is constructed from RACK ENV in def request
Rack::Request.new(self.env)
end Here the middlware probably needs to be self-aware that it's mounted under a specific path and version and method and transform In the short term, you can get the current route information via |
This has been fixed. Path versioning was modifying |
As part of the authentication scheme for my API, the URL the consumer accessed is hashed as part of an authentication token. However, when I access
request.url
in my authentication code, the API prefix and the API version specified are not reflected in the URL:If I
GET /api/v1/employees.json
,request.url
is set tohttp://www.example.com//employees
(note the double slash). Since the consumer, however, is (properly) usinghttp://www.example.com/api/v1/employees
as the URL, the URL on each side does not match up and authentication fails.Any ideas how to fix or get around this?
The text was updated successfully, but these errors were encountered: