Created
February 24, 2012 18:16
-
-
Save tadruj/1902528 to your computer and use it in GitHub Desktop.
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
# This is API module, mapped under /api | |
require 'sinatra/base' | |
module My | |
class API < Sinatra::Base | |
get '/' do | |
'Happy API' | |
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
# This is main app module, mapped under /, where I would like to define additional route in separate file 'fruit.rb' and loading it with load | |
require 'sinatra/base' | |
module My | |
class App < Sinatra::Base | |
get '/' do | |
'Happy App' | |
end | |
load './fruit.rb' | |
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
# I run this with `shotgun -p 5000 app.ru` environment being `RACK_ENV=development` | |
require 'sinatra' | |
require './app' # the file with My::App class | |
require './api' # the file with My::API class | |
disable :run | |
map '/' do | |
run My::App | |
end | |
map '/api' do | |
run My::API | |
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
# This gets loaded with load './fruit.rb' | |
get '/fruit' do | |
'Happy Fruit' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment