def effect_on_response(codes, effect, result):
    """
    Returns the specified effect if the resulting HTTP response code is
    in ``codes``.

    Useful for invalidating auth caches if an HTTP response is an auth-related
    error.

    :param tuple codes: integer HTTP codes
    :param effect: An Effect to perform when response code is in ``codes``.
    :param result: The result to inspect, from an Effect of :obj:`Request`.
    """
    response, content = result
    if response.code in codes:
        return effect.on(success=lambda ignored: result)
    else:
        return result