Last active
August 29, 2015 14:05
-
-
Save regedarek/979cf11df3f69d65db55 to your computer and use it in GitHub Desktop.
Example Versioning App in Sinatra
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
# app/routes/v2/accounts.rb | |
module Oauth2Provider | |
module Routes | |
module V2 | |
class Accounts < Base | |
get '/accounts' do | |
content_type :json | |
'version 2' | |
end | |
end | |
end | |
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
require 'rubygems' | |
require 'bundler' | |
# Setup load paths | |
Bundler.require | |
$: << File.expand_path('../', __FILE__) | |
$: << File.expand_path('../lib', __FILE__) | |
require 'sinatra/base' | |
require 'app/models' | |
require 'app/routes' | |
module Oauth2Provider | |
class App < Sinatra::Application | |
configure do | |
set :database, { | |
adapter: "sqlite3", | |
database: "db/oauthdb.sqlite3" | |
} | |
end | |
use Oauth2Provider::Routes::V1::Accounts | |
use Oauth2Provider::Routes::V2::Accounts | |
end | |
end | |
include Oauth2Provider::Models |
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
require './app' | |
run Oauth2Provider::App |
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
module Oauth2Provider | |
module Routes | |
autoload :Base, 'app/routes/base' | |
# autoload :Accounts, 'app/routes/v2/accounts' | |
module V1 | |
autoload :Accounts, 'app/routes/v1/accounts' | |
end | |
module V2 | |
autoload :Accounts, 'app/routes/v2/accounts' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment