Rack::ContentTypeValidator it's a rack middleware to validate the header Content-Type of requests.
When a ruby webserver receives a request, it validates the Content-Type. Whenever validation fails, the middleware sends a response to client with 415 (Unsupported Media Type) HTTP error.
In your Gemfile:
gem 'rack-content_type_validator'
In your environment.rb:
require 'rack/content_type_validator'
config.middleware.use Rack::ContentTypeValidator
Just 'use Rack::ContentTypeValidator' as any other middleware.
config.middleware.use Rack::ContentTypeValidator, :post, '/posts', {:mime_type => "application/json"}
config.middleware.use Rack::ContentTypeValidator, [:post, :put], '/users', {:mime_type => "application/json"}
config.middleware.use Rack::ContentTypeValidator, :post, '/pages', {:mime_type => "application/xml", :charset => "UTF-8"}
config.middleware.use Rack::ContentTypeValidator, :put, '/pages', {:charset => "ISO-8859-1"}
config.middleware.use Rack::ContentTypeValidator, :put, /\/pages\/.+/, {:charset => "ISO-8859-1"}
config.middleware.use Rack::ContentTypeValidator, :post, '/posts', {:mime_type => "application/json"}
config.middleware.use Rack::ContentTypeValidator, :put, /\/posts\/.+/, {:mime_type => "application/json"}