Skip to content

Commit

Permalink
updates changelog and readme with HTTP 405 (Method Not Allowed) respo…
Browse files Browse the repository at this point in the history
…nse details
  • Loading branch information
gruis committed Sep 30, 2012
1 parent eaa2219 commit eaeb55e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Fixes
* [#181](https://github.com/intridea/grape/pull/181): Fix: Corrected JSON serialization of nested hashes containing `Grape::Entity` instances - [@benrosenblum](https://github.com/benrosenblum).
* [#203](https://github.com/intridea/grape/pull/203): Added a check to `Entity#serializable_hash` that verifies an entity exists on an object - [@adamgotterer](https://github.com/adamgotterer).
* [#208](https://github.com/intridea/grape/pull/208): `Entity#serializable_hash` must also check if attribute is generated by a user supplied block - [@ppadron](https://github.com/ppadron).
* [#252](https://github.com/intridea/grape/pull/252): Resources that don't respond to a requested HTTP method return 405 (Method Not Allowed) instead of 404 (Not Found) [@simulacre](https://github.com/simulacre)

0.2.1 (7/11/2012)
=================
Expand Down
44 changes: 44 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,50 @@ redirect "/new_url"
redirect "/new_url", :permanent => true
```

## Allowed Methods

When you add a route for a resource, a route for the HTTP OPTIONS
method will also be added. The response to an OPTIONS request will
include an Allow header listing the supported methods.

``` ruby
class API < Grape::API
get '/counter' do
{ :counter => Counter.count }
end

params do
requires :value, :type => Integer, :desc => 'value to add to counter'
end
put '/counter' do
{ :counter => Counter.incr(params.value) }
end
end
```

``` shell
curl -v -X OPTIONS http://localhost:3000/counter

> OPTIONS /counter HTTP/1.1
>
< HTTP/1.1 204 No Content
< Allow: OPTIONS, GET, PUT
```


If a request for a resource is made with an unsupported HTTP method, an
HTTP 405 (Method Not Allowed) response will be returned.

``` shell
curl -X DELETE -v http://localhost:3000/counter/

> DELETE /counter/ HTTP/1.1
> Host: localhost:3000
>
< HTTP/1.1 405 Method Not Allowed
< Allow: OPTIONS, GET, PUT
```

## Raising Exceptions

You can abort the execution of an API method by raising errors with `error!`.
Expand Down

0 comments on commit eaeb55e

Please sign in to comment.