Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

fix: handle Starlette routes in FastAPI middleware#136

Merged
sjs994 merged 1 commit into
google:masterfrom
martin1keogh:fix/handle_starlette_routes_in_fastapi_middleware
Nov 14, 2022
Merged

fix: handle Starlette routes in FastAPI middleware#136
sjs994 merged 1 commit into
google:masterfrom
martin1keogh:fix/handle_starlette_routes_in_fastapi_middleware

Conversation

@martin1keogh

Copy link
Copy Markdown
Contributor

This commit changes the FastAPI middleware so that the "route" info is
now optional. If it is not present, the SQL comment will not have the
controller/route info.

This info is always present in FastAPI routes. However, Starlette-based
routes (FastAPI can mount Starlette apps as sub-applications) do not and
would crash when the middleware tried to extract the information.

Fixes #133

@martin1keogh martin1keogh force-pushed the fix/handle_starlette_routes_in_fastapi_middleware branch from 54fb4fd to 75d6a5a Compare June 21, 2022 12:12
@martin1keogh martin1keogh force-pushed the fix/handle_starlette_routes_in_fastapi_middleware branch from e18326e to 3b9fe99 Compare August 12, 2022 12:13
@martin1keogh martin1keogh force-pushed the fix/handle_starlette_routes_in_fastapi_middleware branch from 7c4793c to 76eced6 Compare September 7, 2022 09:25
@Fraser-Isbester

Copy link
Copy Markdown

Bump on this pr?

This commit changes the FastAPI middleware so that the `"route"` info is
now optional. If it is not present, the SQL comment will not have the
controller/route info.

This info is always present in FastAPI routes. However, Starlette-based
routes (FastAPI can mount Starlette apps as sub-applications) do not and
would crash when the middleware tried to extract the information.

Fixes google#133
@sjs994 sjs994 force-pushed the fix/handle_starlette_routes_in_fastapi_middleware branch from 76eced6 to 484494b Compare November 14, 2022 05:25
@sjs994 sjs994 merged commit d7e4758 into google:master Nov 14, 2022
@martin1keogh martin1keogh deleted the fix/handle_starlette_routes_in_fastapi_middleware branch November 14, 2022 08:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastAPI middleware breaks openapi endpoint

3 participants