Skip to content

Instantly share code, notes, and snippets.

@karmi
Created March 30, 2010 17:07
Show Gist options
  • Save karmi/349307 to your computer and use it in GitHub Desktop.
Save karmi/349307 to your computer and use it in GitHub Desktop.
# Match subdomain for a Sinatra route
# cz.application.local:4567 => 200 0K
# en.application.local:4567 => 404 Not Found
# In your /etc/hosts:
# 127.0.0.1 cz.application.local
# 127.0.0.1 en.application.local
require 'rubygems'
require 'sinatra'
def subdomain(host)
condition { host == request.env['HTTP_HOST'].split('.').first }
end
get '/', :subdomain => 'cz' do
"You got yourself a CZ!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment