skillfed

aiohttp-middlewares

Collection of useful middlewares for aiohttp applications.

aiohttp-middlewares v2.4.0 198.5K downloads/30d#9,727 on PyPI54
Permissive license BSD-3-Clause Active released

What it is and what it does

aiohttp-middlewares is a curated collection of middleware functions designed to fill gaps in aiohttp.web's built-in middleware offerings. It addresses common web-development patterns—CORS header injection, centralized error handling, request shielding—that developers would otherwise implement themselves. The package works as a drop-in set of middleware factories that you pass to aiohttp's Application constructor.

The package depends on aiohttp, async-timeout, and yarl, all standard async-web components. It is actively maintained, supports Python 3.8 through 3.12, and carries no known security vulnerabilities. The BSD-3-Clause license permits use in any project type.

Use it for:

  • Enable CORS headers for cross-origin requests in a single middleware registration.
  • Centralize error handling and HTTP exception responses across all routes.
  • Shield view handlers from cancellation during request processing.
  • Add request/response logging or timing middleware to an aiohttp application.
  • Implement common security headers or request validation patterns without custom code.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a collection of ready-to-use middlewares for aiohttp.web applications, covering common needs like CORS headers, error handling, and request shielding.

Yes. Active maintenance, no vulnerabilities, low install friction, and a permissive license make this a safe choice. Install it if you are building an aiohttp.web application and want to avoid writing standard middleware boilerplate for CORS, error handling, or similar cross-cutting concerns.

Install

aiohttp-middlewares on PyPI

pip

pip install aiohttp-middlewares

uv

uv add aiohttp-middlewares

poetry

poetry add aiohttp-middlewares

Installing aiohttp-middlewares

Before you install

Low install friction with a pure-Python wheel. Active maintenance with a recent commit on 2026-03-30 and stable production status.

License in practice

BSD-3-Clause is permissive; you can use this in commercial and proprietary projects with minimal restrictions, provided you include the license text.

Quickstart

pip install aiohttp-middlewares

from aiohttp import web
from aiohttp_middlewares import cors_middleware, error_middleware

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

Requires aiohttp 3.8.1 or later and Python 3.8+.

Verify before relying

  • Whether all advertised middlewares are documented and which ones are most commonly used in production.
  • Performance characteristics when stacking multiple middlewares on high-traffic applications.

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (<4.0,>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 3 — aiohttp, async-timeout, yarl
Maintenance actively maintained — 730 days since the last release
Last repo commit
First released
Downloads 198,526/month — #9,727 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aiohttp_middlewares-2.4.0-py3-none-any.whl

Keywords: aiohttp, aiohttp-server, middlewares, aiohttp-middlewares

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: AsyncIOFramework :: aiohttpIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: WSGI :: MiddlewareTopic :: UtilitiesTyping :: Typed

Tags

aiohttp middleware collectionaiohttp cors middlewareaiohttp error handlingaiohttp web utilitiesasync web middlewareaiohttp request middlewareaiohttp application middleware
aiohttpasync-webmiddleware

More WWW/HTTP packages