MethodExceptionΒΆ

While defining routes or using the @allow_methods decorator you can specify the allowed HTTP methods to support, the ZunZun instance, internally will verify for the corret method, otherwise will raise an MethodException

The MethodException behaves similar to the HTTPException the only difference is that by default sets the status code to 405 Method Not Allowed

MethodException(status=405, title=None, description=None, headers=None, code=None, display=False)

For example the zun_exception.py custom module only accepts ‘GET’ methods from this code snippet:

@tools.allow_methods('get')
def dispatch(self, request, response):

Therefor if you try the following:

curl -i -X HEAD http://api.zunzun.io/exception/foo
  • Note the: -X HEAD this will send a HEAD request not a GET

The answer will be simillar to:

1
2
3
4
5
6
7
HTTP/1.1 405 Method Not Allowed
Request-ID: 52c6ac4e00ff060346c67c66450001737e7a756e7a756e6369746f2d617069000131000100
Content-Type: application/json; charset=UTF-8
Date: Fri, 03 Jan 2014 12:25:50 GMT
Server: Google Frontend
Content-Length: 0
Alternate-Protocol: 80:quic,80:quic

Many thanks Paw - The ultimate REST client for Mac. for supporting Open Source projects.

paw

A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.

Donating helps ensure continued support, development and availability.

dalmp


comments powered by Disqus