Metadata-Version: 2.1
Name: buvar_aiohttp
Version: 0.4.5
Summary: aiohttp plugin for buvar
Home-page: https://gitlab.com/diefans/buvar
Author: Oliver Berger
Author-email: diefans@gmail.com
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Framework :: AsyncIO
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.7,<4.0
Description-Content-Type: text/x-rst
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Requires-Dist: buvar>=0.42.3
Requires-Dist: aiohttp
Requires-Dist: attrs>=19.1
Requires-Dist: structlog
Requires-Dist: pendulum
Requires-Dist: uritools
Provides-Extra: tests
Requires-Dist: pytest>=4.6; extra == "tests"
Requires-Dist: pytest-cov<3.0,>=2.7; extra == "tests"
Requires-Dist: pytest-asyncio>=0.11.0; extra == "tests"
Requires-Dist: pytest-benchmark<4.0,>=3.2.2; extra == "tests"
Requires-Dist: mock<4.0,>=3.0; extra == "tests"
Requires-Dist: pytest-mock<2.0,>=1.10; extra == "tests"
Requires-Dist: pytest-watch<5.0,>=4.2; extra == "tests"
Requires-Dist: pytest-randomly<4.0,>=3.1; extra == "tests"
Requires-Dist: pytest-doctestplus<1.0,>=0.5; extra == "tests"
Requires-Dist: pytest-aiohttp; extra == "tests"
Requires-Dist: pytest-anything; extra == "tests"
Requires-Dist: pdbpp; extra == "tests"

buvar_aiohttp
=============

Solves some boilerplate around starting an `aiohttp`_ server.

.. code-block:: python

    import aiohttp.web
    from buvar import context, di, fork, plugin

    from buvar_aiohttp import AioHttpConfig


    async def hello(request):
        return aiohttp.web.Response(body=b"Hello, world")


    async def prepare_aiohttp(load: plugin.Loader):
        # provide config
        context.add(AioHttpConfig(host="0.0.0.0", port=5678))

        # prepare server site
        await load("buvar_aiohttp")

        # mount routes
        app = await di.nject(aiohttp.web.Application)
        app.router.add_route("GET", "/", hello)


    # start a process for each available CPU and provide a shared socket to all
    # children
    fork.stage(prepare_aiohttp, forks=0, sockets=["tcp://:5678"])


.. _aiohttp: https://docs.aiohttp.org
