aiohttp_utils/negotiation.py
def setup(
    app: web.Application, *, negotiator: callable=DEFAULTS['NEGOTIATOR'],
    renderers: OrderedDict=DEFAULTS['RENDERERS'],
    force_negotiation: bool=DEFAULTS['FORCE_NEGOTIATION']
):
    """Set up the negotiation middleware. Reads configuration from
    ``app['AIOHTTP_UTILS']``.

    :param app: Application to set up.
    :param negotiator: Function that selects a renderer given a
        request, a dict of renderers, and a ``force`` parameter (whether to return
        a renderer even if the client passes an unsupported media type).
    :param renderers: Mapping of mediatypes to callable renderers.
    :param force_negotiation: Whether to return a rennderer even if the
        client passes an unsupported media type).
    """
    config = app.get(CONFIG_KEY, {})
    middleware = negotiation_middleware(
        renderers=config.get('RENDERERS', renderers),
        negotiator=config.get('NEGOTIATOR', negotiator),
        force_negotiation=config.get('FORCE_NEGOTIATION', force_negotiation)
    )
    app.middlewares.append(middleware)
    return app
def setup(
    app: web.Application, *, negotiator: callable=DEFAULTS['NEGOTIATOR'],
    renderers: OrderedDict=DEFAULTS['RENDERERS'],
    force_negotiation: bool=DEFAULTS['FORCE_NEGOTIATION']
):
    """Set up the negotiation middleware. Reads configuration from
    ``app['AIOHTTP_UTILS']``.

    :param app: Application to set up.
    :param negotiator: Function that selects a renderer given a
        request, a dict of renderers, and a ``force`` parameter (whether to return
        a renderer even if the client passes an unsupported media type).
    :param renderers: Mapping of mediatypes to callable renderers.
    :param force_negotiation: Whether to return a rennderer even if the
        client passes an unsupported media type).
    """
    config = app.get(CONFIG_KEY, {})
    middleware = negotiation_middleware(
        renderers=config.get('RENDERERS', renderers),
        negotiator=config.get('NEGOTIATOR', negotiator),
        force_negotiation=config.get('FORCE_NEGOTIATION', force_negotiation)
    )
    app.middlewares.append(middleware)
    return app
def setup ( app : web . Application , * , negotiator : callable = DEFAULTS [ 'NEGOTIATOR' ] , renderers : OrderedDict = DEFAULTS [ 'RENDERERS' ] , force_negotiation : bool = DEFAULTS [ 'FORCE_NEGOTIATION' ] ) : config = app . get ( CONFIG_KEY , { } ) middleware = negotiation_middleware ( renderers = config . get ( 'RENDERERS' , renderers ) , negotiator = config . get ( 'NEGOTIATOR' , negotiator ) , force_negotiation = config . get ( 'FORCE_NEGOTIATION' , force_negotiation ) ) app . middlewares . append ( middleware ) return app
Set up the negotiation middleware. Reads configuration from
    ``app['AIOHTTP_UTILS']``.

    :param app: Application to set up.
    :param negotiator: Function that selects a renderer given a
        request, a dict of renderers, and a ``force`` parameter (whether to return
        a renderer even if the client passes an unsupported media type).
    :param renderers: Mapping of mediatypes to callable renderers.
    :param force_negotiation: Whether to return a rennderer even if the
        client passes an unsupported media type).
Set up the negotiation middleware . Reads configuration from app [ AIOHTTP_UTILS ] .