Skip to content

Instantly share code, notes, and snippets.

@akahn
Forked from karmi/subdomains_in_sinatra.rb
Created March 30, 2010 17:08
Show Gist options
  • Save akahn/349309 to your computer and use it in GitHub Desktop.
Save akahn/349309 to your computer and use it in GitHub Desktop.
karmi rules
# 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