Closed
Description
The example code for starlette proposes to use the middleware
decorator: https://secure.readthedocs.io/en/latest/frameworks.html#starlette
Anyhow, this decorator is deprecated, and will be removed in version 1.0.0 - at least there is a warning about that.
The message is:
[...]/site-packages/starlette/applications.py:248: DeprecationWarning: The `middleware` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/middleware/#using-middleware for recommended approach.
It would be good to update the help.
I'm using this now, but would not say that I'm confident this is the correct solution:
class SecureHeadersMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
response = await call_next(request)
secure_headers.framework.starlette(response)
return response
app.add_middleware(SecureHeadersMiddleware)
Metadata
Metadata
Assignees
Labels
No labels