README.md in sinatra-subdomain-0.2.1 vs README.md in sinatra-subdomain-0.3.0

- old
+ new

@@ -18,18 +18,18 @@ require "sinatra" require "sinatra/subdomain" # Specify which subdomain you want subdomain :foo do - get '/' do + get "/" do "render page for FOO" end end # If any subdomain is set subdomain do - get '/' do + get "/" do "render page for #{subdomain} subdomain" end end ``` @@ -42,34 +42,53 @@ # Specify which subdomain you want class MyApp < Sinatra::Base register Sinatra::Subdomain subdomain :foo do - get '/' do + get "/" do "render page for FOO" end end # If any subdomain is set subdomain do - get '/' do + get "/" do "render page for #{subdomain} subdomain" end end end ``` +You can also pass an array or regular expressions to match subdomains: + +```ruby +class MyApp < Sinatra::Base + register Sinatra::Subdomain + + subdomain [:foo, :bar, :zaz] do + get "/" do + "render page for #{subdomain}" + end + end + + # Matches www, www1, www2, etc. + subdomain /\Awww\d*\z/ do + get "/" do + "render page for #{subdomain} subdomain" + end + end +end +``` + By default, sinatra-subdomain will consider 1 TLD as in <tt>example.com</tt>. You can specify your TLD size for domains like <tt>example.com.br</tt> or <tt>example.co.uk</tt>. ```ruby require "sinatra" require "sinatra/subdomain" set :tld_size, 2 ``` - -This extension was based on http://github.com/akahn/sinatra-subdomain/ # License (The MIT License)