Skip to content

Commit

Permalink
⬆️ Upgrade Starlette and fix compatibility (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Feb 19, 2019
1 parent 656e1c7 commit ba10838
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ python-multipart = "*"
sqlalchemy = "*"

[packages]
starlette = "==0.10.1"
starlette = "==0.11.1"
pydantic = "==0.18.2"

[requires]
Expand Down
81 changes: 36 additions & 45 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions fastapi/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from starlette.applications import Starlette
from starlette.exceptions import ExceptionMiddleware, HTTPException
from starlette.middleware.errors import ServerErrorMiddleware
from starlette.middleware.lifespan import LifespanMiddleware
from starlette.requests import Request
from starlette.responses import JSONResponse, Response
from starlette.routing import BaseRoute


async def http_exception(request: Request, exc: HTTPException) -> JSONResponse:
Expand All @@ -26,6 +26,7 @@ class FastAPI(Starlette):
def __init__(
self,
debug: bool = False,
routes: List[BaseRoute] = None,
template_directory: str = None,
title: str = "Fast API",
description: str = "",
Expand All @@ -37,14 +38,11 @@ def __init__(
**extra: Dict[str, Any],
) -> None:
self._debug = debug
self.router: routing.APIRouter = routing.APIRouter()
self.router: routing.APIRouter = routing.APIRouter(routes)
self.exception_middleware = ExceptionMiddleware(self.router, debug=debug)
self.error_middleware = ServerErrorMiddleware(
self.exception_middleware, debug=debug
)
self.lifespan_middleware = LifespanMiddleware(self.error_middleware)
self.schema_generator = None
self.template_env = self.load_template_env(template_directory)

self.title = title
self.description = description
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
]
requires = [
"starlette >=0.9.11,<=0.10.1",
"starlette ==0.11.1",
"pydantic >=0.17,<=0.18.2"
]
description-file = "README.md"
Expand Down

0 comments on commit ba10838

Please sign in to comment.