intridea/grape — pull request #809 by ajvondrak (2014-11-11 22:05:25+00:00)
Title: Don't use `.format` suffix in paths if you only have one format

For example, say you have the following API:

```ruby
require 'grape'

class API < Grape::API
format :json

get :hello do
{ hello: 'world' }
end
end

run API
```

If you hit `/hello`, you'd get back the JSON `{"hello":"world"}`. This makes sense: you specifically say that your format is JSON.

However, before this commit, you could also hit `/hello.xml`, which would confusingly return the *JSON* `{"hello":"world"}`. Why bother exposing this path as a valid API endpoint when we're just going to ignore the format anyway?

In this commit, `/hello.xml` (or `/hello.json` or `/hello.foobar`) will all be 404s. We don't even entertain the notion of an optional format path parameter.

Old behavior is still preserved if you add different content types after your `format :xxx` declaration. So, if you have the following API:

```ruby
require 'grape'

class API < Grape::API
format :json
content_type :xml, 'application/xml'

get :hello do
{ hello: 'world' }
end
end

run API
```

then `/hello`, `/hello.json`, `/hello.xml`, and `/hello.foobar` all return the JSON `{"hello":"world"}`. I don't know why you'd want this behavior either, but it was being enforced by the specs, so I preserved it.

What do you think?