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

API v2 - specify API version via headers or in url #3431

Closed
wants to merge 6 commits into from
Closed

API v2 - specify API version via headers or in url #3431

wants to merge 6 commits into from

Conversation

komidore64
Copy link
Contributor

No description provided.

@daviddavis
Copy link
Contributor

It would be nice to have some tests for this with assert_routing/assert_generates/assert_recognizes. It doesn't have to be this PR though. Maybe open a Red Mine issue for it?

req.accept =~ /version=([\d\.]+)/
if (version = $1) # version is specified in header
header_match = req.accept.match(/version=([\d\.]+)/)
route_match = req.fullpath.match(/api\/v\d\//)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if %r{api/v\d/} would be easier to read here?

@daviddavis
Copy link
Contributor

ACK pending comments and Jenkins.

Thanks again for working on this.

@daviddavis
Copy link
Contributor

Opened issue http://projects.theforeman.org/issues/3754 for the tests

ACK pending Jenkins.

@@ -18,8 +18,13 @@ def initialize(options)
end

def matches?(req)
req.accept =~ /version=([\d\.]+)/
if (version = $1) # version is specified in header
header_match = req.accept.match(/version=([\d\.]+)/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like request.accept could return nil. If you update this to the following, I think it should fix the breaking test:

header_match = req.accept.try(:match, /version=([\d\.]+)/)

@komidore64
Copy link
Contributor Author

closing due to merge of engine branch into master.

PR continued in #3461.

@komidore64 komidore64 closed this Dec 4, 2013
@komidore64 komidore64 deleted the versioned-urls branch December 4, 2013 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants