.. _request-handlers:

Request handlers (propeller.RequestHandler)
===========================================

Request handlers are the classes that handle requests from clients. Extend ``propeller.RequestHandler`` to define a request handler::

    from propeller import RequestHandler

    class HomeHandler(RequestHandler):
        pass


Propeller will call the ``get()``, ``post()``, ``put()``, ``delete()``, ``head()``, and ``options()`` methods on your request handler, depending on the HTTP method used by the client. These methods will receive an instance of the :ref:`request-object` as their first argument (after ``self``), followed by any arguments for each matched group from the URL's regular expression.

Your request handler's methods should always return an instance of the :ref:`response-object`.

An example of a request handler that responds to POST requests::

    from propeller import RequestHandler, Response

    class UserHandler(RequestHandler):
        def post(self, request):
            # do stuff
            return Response('User saved')
