Skip to content

Instantly share code, notes, and snippets.

@jcran
Created September 17, 2012 17:42
Show Gist options
  • Save jcran/3738708 to your computer and use it in GitHub Desktop.
Save jcran/3738708 to your computer and use it in GitHub Desktop.
===== config.ru
require 'api' # Loads the app(s)
map("/v1/component_a") do
run Sinatra.new(Pwnix::ComponentA)
end
map("/v1/component_b") do
run Sinatra.new(Pwnix::ComponentB)
end
===== end config.ru
===== api.rb
# Gems
require 'sinatra/base'
require 'sinatra/namespace'
require 'json'
# Load Component Routes
require_relative 'controllers/componenta'
require_relative 'controllers/componentb'
# Load Libraries
require_relative 'componenta/init'
require_relative 'componentb/init'
===== end api.rb
===== componenta.rb
class ComponentA < Sinatra::Base
# Namespace Library
register Sinatra::Namespace
get '/something' do
"hello from component a"
end
end
===== end componenta.rb
===== componentb.rb
class ComponentB < Sinatra::Base
# Namespace Library
register Sinatra::Namespace
get '/something' do
"hello from component b"
end
end
===== end componentb.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment