aio-libs / aio-libs/aiohttp

[Discussion] Ordering of middlewares=

Đang mở
#6,798 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

### Describe the bug

Some users try to use `Application(middlewares=...)` and then use the `setup()` functions from other libraries, which add their own middlewares.

This can cause problems due to the ordering of middlewares. I suspect that passing a list of middlewares like this makes users less aware of the ordering of middlewares at the end of their setup.

Maybe we should consider disallowing the passing of middlewares and require later `app.middlewares.append()` etc.?

Or, lock the middlewares when they have been passed in, such that it can't be mixed with `.append()` or `setup()`. This allows a user to pass a fixed sequence of middlewares that will never change. If they need to use `setup()` or similar, then they must add all their middlewares as a separate step, paying attention to what order to add them along with the `setup()` calls.

### Additional context

#6789

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.