human
Complete this python program:
def _endpoint(name, ignore_body=False):
assistant
#Here is the Python program you requested.

    """Decorator factory for API endpoints, adding appropriate JSON in/out
    encoding.
    This also converts errors and ``BadRequest`` exceptions to JSON that
    can be read by Docker and therefore shown to the user.
    :param unicode name: The name of the endpoint in the schema.
    :param ignore_body: If true, ignore the contents of the body for all
    HTTP methods, including ``POST``. By default the body is only
    ignored for ``GET`` and ``HEAD``.
    :return: Decorator for a method.
    """
    def decorator(f):
        @wraps(f)
        @structured(inputSchema={}, outputSchema={u'$ref': (u'/endpoints.json#/definitions/' + name)}, schema_store=SCHEMAS, ignore_body=ignore_body)
        def wrapped(*args, **kwargs):
            d = maybeDeferred(f, *args, **kwargs)
            def handle_error(failure):
                if failure.check(BadRequest):
                    code = failure.value.code
                    body = failure.value.result
                else:
                    writeFailure(failure)
                    code = OK
                    body = {u'Err': u'{}:    {}'.format(failure.type.__name__, failure.value)}
                return EndpointResponse(code, body)
            d.addErrback(handle_error)
            return d
        return wrapped
    return decorator