refactor ContentTypeFilter and gracefully handle invalid json params

I've refactored your ContentTypeFilter code and added a rack middleware to gracefully handle malformed json params for API routes only when `content_type = application_json`.