title: constraints :subdomain
body: <p>How to use</p>
  
  <pre><code>constraints :subdomain =&gt; 'api',:format =&gt; :json do
  end
  </code></pre>
  
  <p>and all others like www,nil and generics to redirect to www or nil (domain).</p>
  
  <p>No generic subdomain, just api and only format json.</p>
  
  <pre><code>constraints :subdomain =&gt; 'api',:format =&gt; :json do
     root :to =&gt; "posts#index", :defaults =&gt; { :format =&gt; :json }
     get "posts" =&gt; "posts#index", :defaults =&gt; { :format =&gt; :json }
  end
  </code></pre>
  
  <p>How to get default json if I access from api.domain.com/posts instead of /posts.json
  This is not must have feature, but is cool. 
  Now I need an redirect to domain if request is not json or not Found or render as json.</p>
  
  <pre><code>api.domain.com/posts
  </code></pre>
  
  <p>Should: 
      render as json, redirect to domain.com/post or show not found page.</p>