Add documentation for returning specific HTTP status codes.

This commit is contained in:
Ryan Petrello
2013-03-12 13:02:23 -04:00
parent 2c58651b04
commit 125b3ad2e0

View File

@@ -134,6 +134,35 @@ methods on your controller objects provides additional flexibility for
processing all or part of a URL.
Setting a Return Status Code
--------------------------------
Setting a specific HTTP response code (such as ``201 Created``) is simple:
::
from pecan import expose, response
class RootController(object):
@expose('json')
def hello(self):
response.status = 201
return {'foo': 'bar'}
Pecan also comes with ``abort``, a utility function for raising HTTP errors:
::
from pecan import expose, abort
class RootController(object):
@expose('json')
def hello(self):
abort(404)
Routing to Subcontrollers with ``_lookup``
------------------------------------------