Изменения мидлваре
This commit is contained in:
parent
a5785a5577
commit
d3bff12f40
1 changed files with 4 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import logging
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
@ -36,7 +38,9 @@ app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
|||
|
||||
class AddHeaderMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
logging.critical(request.headers)
|
||||
response = await call_next(request)
|
||||
logging.critical(response.headers)
|
||||
if "Sec-Websocket-Protocol" in request.headers:
|
||||
raise ValueError(request.headers["Sec-Websocket-Protocol"])
|
||||
response.headers["Sec-Websocket-Protocol"] = request.headers["Sec-Websocket-Protocol"]
|
||||
|
|
Loading…
Add table
Reference in a new issue