human
Complete this python program:
def before(action):
assistant
#Here is the Python program you requested.

    """Decorator to execute the given action function *before* the responder.
    Args:
    action (callable): A function of the form
    ``func(req, resp, resource, params)``, where `resource` is a
    reference to the resource class instance associated with the
    request, and `params` is a dict of URI Template field names,
    if any, that will be passed into the resource responder as
    kwargs.
    Note:
    Hooks may inject extra params as needed. For example::
    def do_something(req, resp, resource, params):
    try:
    params[\id\] = int(params[\id\])
    except ValueError:
    raise falcon.HTTPBadRequest(\Invalid ID\,
    \ID was not valid.\)
    params[\answer\] = 42
    """
    def _before(responder_or_resource):
        if isinstance(responder_or_resource, six.class_types):
            resource = responder_or_resource
            for method in HTTP_METHODS:
                responder_name = ('on_' + method.lower())
                try:
                    responder = getattr(resource, responder_name)
                except AttributeError:
                    pass
                else:
                    if callable(responder):
                        def let(responder=responder):
                            do_before_all = _wrap_with_before(action, responder)
                            setattr(resource, responder_name, do_before_all)
                        let()
            return resource
        else:
            responder = responder_or_resource
            do_before_one = _wrap_with_before(action, responder)
            return do_before_one
    return _before