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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment