crepe/crepe — pull request #60 by stephencelis (2014-07-22 16:26:26+00:00)
Title: Add more flexible parsing

As it stands, Parser::Simple is, on its own, too simple.

While Endpoint splits responsibility between acceptance and rendering, Endpoint does no such thing between supported media types and parsing.

Why do we need granularity here? Well, the parser supports `application/x-www-form-urlencoded` and `multipart/form-data` by default. This seemed like a good idea at a time, but it actually makes Crepe a bit more difficult to step into because the first time you `curl`-debug, the params you expect to be parsed in from JSON will be `nil` unless you explicitly add `-H "Content-Type: application/json"`. If it returned early with `415 Unsupported Media Type`, it would be a lot easier to debug.

Renderer::Simple supports `to_#{format}` for any format by default, so we shouldn't need to get rid of form data support, but Renderer::Simple won't get hit at all if the format hasn't been whitelisted. We need the same ability to whitelist supported media types.

This commit adds and configures a list of media types an endpoint will parse. In order to parse form data, you must be explicit with the media type, _e.g._:

``` rb
parses 'application/x-www-form-urlencoded', 'multipart/form-data'
# or parses(*Rack::Request::FORM_DATA_MEDIA_TYPES)
```