<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def response_middleware(api=None):
 """Registers a middleware function that will be called on every response"""

    def decorator(middleware_method):
        apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_method)

        class MiddlewareRouter(object):
            __slots__ = ()

            def process_response(self, request, response, resource, req_succeeded):
                return middleware_method(request, response, resource)

        apply_to_api.http.add_middleware(MiddlewareRouter())
        return middleware_method
    return decorator