Metadata-Version: 2.4
Name: aiohttp-middlewares
Version: 3.0.0
Summary: Collection of useful middlewares for aiohttp applications.
Keywords: aiohttp,aiohttp-middlewares,aiohttp-server,middlewares
Author: Igor Davydenko
Author-email: Igor Davydenko <iam@igordavydenko.com>
License-Expression: BSD-3-Clause
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: aiohttp
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: aiohttp>=3.11.0,<4.0.0
Requires-Dist: async-timeout>=4.0.2,<6.0.0 ; python_full_version < '3.11'
Requires-Dist: yarl>=1.17.0,<2.0.0
Requires-Python: >=3.10, <4.0
Project-URL: Bug Tracker, https://github.com/playpauseandstop/aiohttp-middlewares/issues
Project-URL: homepage, https://igordavydenko.com/projects.html#aiohttp-middlewares
Project-URL: repository, https://github.com/playpauseandstop/aiohttp-middlewares
Project-URL: documentation, https://aiohttp-middlewares.readthedocs.io/
Description-Content-Type: text/x-rst

===================
aiohttp-middlewares
===================

|Latest version| |Python versions| |License| |Documentation|

.. |Latest version| image:: https://img.shields.io/pypi/v/aiohttp-middlewares.svg
    :target: https://pypi.org/project/aiohttp-middlewares/
    :alt: Latest version
.. |Python versions| image:: https://img.shields.io/pypi/pyversions/aiohttp-middlewares.svg
    :target: https://pypi.org/project/aiohttp-middlewares/
    :alt: Python versions
.. |License| image:: https://img.shields.io/pypi/l/aiohttp-middlewares.svg
    :target: https://github.com/playpauseandstop/aiohttp-middlewares/blob/main/LICENSE
    :alt: BSD License
.. |Documentation| image:: https://readthedocs.org/projects/aiohttp-middlewares/badge/?version=latest
    :target: http://aiohttp-middlewares.readthedocs.org/en/latest/
    :alt: Documentation

|CI| |pre-commit| |black| |isort| |mypy| |zizmor| |Coverage|

.. |CI| image:: https://github.com/playpauseandstop/aiohttp-middlewares/actions/workflows/ci.yml/badge.svg
    :target: https://github.com/playpauseandstop/aiohttp-middlewares/actions/workflows/ci.yml
    :alt: CI Workflow
.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
    :target: https://github.com/pre-commit/pre-commit
    :alt: pre-commit
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: black
.. |isort| image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
    :target: https://pycqa.github.io/isort/
    :alt: Imports: isort
.. |mypy| image:: https://www.mypy-lang.org/static/mypy_badge.svg
    :target: https://mypy-lang.org/
    :alt: Checked with mypy
.. |zizmor| image:: https://img.shields.io/badge/%F0%9F%8C%88-zizmor-white?labelColor=white
    :target: https://zizmor.sh/
    :alt: zizmor
.. |Coverage| image:: https://coveralls.io/repos/playpauseandstop/aiohttp-middlewares/badge.svg?branch=main&service=github
    :target: https://coveralls.io/github/playpauseandstop/aiohttp-middlewares
    :alt: Coverage

Collection of useful middlewares for `aiohttp.web`_ applications.

- Works on `Python`_ 3.10+
- Works with `aiohttp.web`_ 3.11.0+
- BSD licensed
- Latest documentation `on Read The Docs
  <https://aiohttp-middlewares.readthedocs.io/>`_
- Source, issues, and pull requests `on GitHub
  <https://github.com/playpauseandstop/aiohttp-middlewares>`_

.. _`aiohttp.web`: https://docs.aiohttp.org/en/stable/web.html
.. _`Python`: https://www.python.org/

Quick Start
===========

By default ``aiohttp.web`` does not provide `many built-in middlewares
<https://docs.aiohttp.org/en/stable/web_reference.html#middlewares>`_ for
standart web-development needs such as: handling errors, shielding view
handlers, or providing CORS headers.

``aiohttp-middlewares`` tries to fix this by providing several middlewares that
aims to cover most common web-development needs.

For example, to enable CORS headers for ``http://localhost:8081`` origin and
handle errors for ``aiohttp.web`` application you need to,

.. code-block:: python

    from aiohttp import web
    from aiohttp_middlewares import (
        cors_middleware,
        error_middleware,
    )

    app = web.Application(
        middlewares=(
            cors_middleware(origins=("http://localhost:8081",)),
            error_middleware(),
        )
    )

Check `documentation <https://aiohttp-middlewares.readthedocs.io/>`_ for
all available middlewares and available initialization options.
