-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drop with_plugins from middleware
- Loading branch information
Showing
14 changed files
with
135 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.5.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- id: no-commit-to-branch | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
from starlette.applications import Starlette | ||
from starlette.middleware import Middleware | ||
from starlette.requests import Request | ||
from starlette.responses import JSONResponse | ||
|
||
import uvicorn | ||
from examples.example_with_logger.logger import log | ||
from starlette_context import context, middleware, plugins | ||
|
||
app = Starlette(debug=True) | ||
middleware = [ | ||
Middleware( | ||
middleware.ContextMiddleware, | ||
plugins=( | ||
plugins.CorrelationIdPlugin(), | ||
plugins.RequestIdPlugin(), | ||
plugins.DateHeaderPlugin(), | ||
plugins.ForwardedForPlugin(), | ||
plugins.UserAgentPlugin(), | ||
), | ||
) | ||
] | ||
|
||
app = Starlette(debug=True, middleware=middleware) | ||
|
||
|
||
@app.route("/") | ||
async def index(request: Request): | ||
async def index(_: Request): | ||
log.info("Log from view") | ||
return JSONResponse(context.data) | ||
|
||
|
||
app.add_middleware( | ||
middleware.ContextMiddleware.with_plugins( | ||
plugins.CorrelationIdPlugin, | ||
plugins.RequestIdPlugin, | ||
plugins.DateHeaderPlugin, | ||
plugins.ForwardedForPlugin, | ||
plugins.UserAgentPlugin, | ||
) | ||
) | ||
uvicorn.run(app, host="0.0.0.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ autoflake | |
mypy | ||
black | ||
isort | ||
pre-commit-hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import setuptools | ||
|
||
VERSION = "0.2.0" | ||
VERSION = "0.2.1" | ||
|
||
|
||
def get_long_description(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.