Permalink
Browse files

Give an example of how to use this extension when using Sinatra modul…

…ar style.
  • Loading branch information...
1 parent 7e21cc2 commit d2385e1bd5657f377b48ec1aa62dba810f9d4600 @everythingbehind everythingbehind committed with Apr 22, 2010
Showing with 26 additions and 3 deletions.
  1. +3 −3 example_app.rb → example_classic_app.rb
  2. +23 −0 example_modular_app.rb
@@ -1,8 +1,8 @@
require 'sinatra'
require 'sinatra/subdomain'
-# This is an example application that uses sinatra-subdomain. Start it using
-# `shotgun -I lib example_app.rb`. Then visit http://smackaho.st:9393 and
+# This is an example of a classic application that uses sinatra-subdomain. Start it using
+# `shotgun -I lib example_classic_app.rb`. Then visit http://smackaho.st:9393 and
# http://foo.smackaho.st:9393 to use the application.
subdomain :foo do |sub|
@@ -14,4 +14,4 @@
get '/' do
"Home!"
-end
+end
View
@@ -0,0 +1,23 @@
+require 'sinatra/base'
+require 'sinatra/subdomain'
+
+# This is an example of a classic application that uses sinatra-subdomain.
+# You'll need a config.ru as follows:
+# require 'example_modular_app'
+# run Hello
+# Start it using `shotgun -I lib example_modular_app.rb`. Then visit http://smackaho.st:9393 and
+# http://foo.smackaho.st:9393 to use the application.
+
+class Hello < Sinatra::Base
+ register Sinatra::Subdomain
+
+ subdomain :foo do |sub|
+ get '/' do
+ "You are on: #{sub}"
+ end
+ end
+
+ get '/' do
+ "Home!"
+ end
+end

0 comments on commit d2385e1

Please sign in to comment.