doc: fix middleware (#471)

This commit is contained in:
Daniel Hahler 2019-04-10 14:14:24 +02:00 committed by Tom Christie
parent e37ec7e561
commit 60c0be1e50
1 changed files with 2 additions and 2 deletions

View File

@ -165,13 +165,13 @@ app.add_middleware(CustomHeaderMiddleware)
If you want to provide configuration options to the middleware class you should
override the `__init__` method, ensuring that the first argument is `app`, and
any remaining arguments are optional keyword arguments. Make sure to set the `app`
attribute on the class if you do this.
attribute on the instance if you do this.
```python
class CustomHeaderMiddleware(BaseHTTPMiddleware):
def __init__(self, app, header_value='Example'):
self.app = app
self.header_value
self.header_value = header_value
async def dispatch(self, request, call_next):
response = await call_next(request)