title: Creating a route with Sinatra to only accept a certain Content-type
body: <p>I'm trying to create a route with Sinatra that only accepts POST with an <code>Content-type: application/json</code> without success.</p>
  
  <p>My approach is as follows:</p>
  
  <pre><code>post '/dogs', :provides =&gt; :json do
    # returns here a json response
  end
  </code></pre>
  
  <p>Testing with curl, I have seen that <code>:provides =&gt; :json</code> configures the route to respond with an <code>Content-Type: application/json</code>. </p>
  
  <p>That's right because I want also to respond with a JSON message to the POST request but I really need that this route only respond to POST requests with a <code>Content-Type: application/json</code> and not, for example, to others (e.g. <code>Content-Type: application/xml</code>).</p>
  
  <p>Is there any way in Sinatra to restrict the route to only accept requests with a certain <code>Content-Type</code>?</p>