Created
August 14, 2012 08:51
-
-
Save anonymous/3347608 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ # Problem: Divide api into version to provide a consistent experience to developers. require 'goliath' require 'active_support/all' module V01 class Hello def self.call(env) [200, {}, {'response' => 'V01'}] end end end module V02 class Hello def self.call(env) [200, {}, {'response' => 'V02'}] end end end class HelloApp < Goliath::API use Goliath::Rack::Params def response(env) version = env['HTTP_ACCEPTS'].tr('^0-9','') version = "V"+version version.to_s.constantize::Hello.call(env) end end