kangda-robot-backend/ruoyi-fastapi-backend/middlewares/gzip_middleware.py

17 lines
524 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from fastapi import FastAPI
def add_gzip_middleware(app: FastAPI):
"""
添加gzip压缩中间件 - 已禁用
注意: 由于SSE流式响应需要实时传输gzip压缩被禁用
SSE数据流很小压缩意义不大反而会影响实时性
:param app: FastAPI对象
:return:
"""
# 暂时禁用GZip中间件以支持SSE流式响应
# 如果需要重新启用,请取消下面的注释
# app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=9)
pass