Created
May 31, 2013 01:28
-
-
Save austenito/5682453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Router | |
class ApiConstraints | |
def initialize(options) | |
@version = options[:version] | |
@default = options[:default] | |
end | |
def default? | |
@default | |
end | |
def matches?(request) | |
default? || request.headers['Accept'].include?("application/vnd.customer_profile_service.v#{@version}") | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :api, defaults: {format: 'json'} do | |
scope module: :v1, constraints: Router::ApiConstraints.new(version: 1, default: true) do | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment