Created
May 1, 2014 06:15
-
-
Save slowjud/29cf08db413453fe83cb to your computer and use it in GitHub Desktop.
Version Accept headers
This file contains 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
class ApiConstraints | |
def initialize(options) | |
@version = options[:version] | |
@default = options[:default] | |
end | |
def matches?(req) | |
@default || req.headers['Accept'].include?("application/vnd.betterbills.v#{@version}") | |
end | |
end |
This file contains 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
ApiService::Application.routes.draw do | |
namespace :person_service, defaults: {format: 'json'} do | |
scope module: :v1, constraints: ApiConstraints.new(version: 1) do | |
get '/people', to: 'people#index' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment