mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +00:00
fastapi_paths to tuple and simplified startswith check
This commit is contained in:
parent
ca2c46a6e3
commit
80adc42614
1 changed files with 3 additions and 3 deletions
|
@ -230,13 +230,13 @@ class TracingMiddleware:
|
||||||
self.app = app
|
self.app = app
|
||||||
self.impls = impls
|
self.impls = impls
|
||||||
# FastAPI built-in paths that should bypass custom routing
|
# FastAPI built-in paths that should bypass custom routing
|
||||||
self.fastapi_paths = [
|
self.fastapi_paths = (
|
||||||
"/docs",
|
"/docs",
|
||||||
"/redoc",
|
"/redoc",
|
||||||
"/openapi.json",
|
"/openapi.json",
|
||||||
"/favicon.ico",
|
"/favicon.ico",
|
||||||
"/static"
|
"/static"
|
||||||
]
|
)
|
||||||
|
|
||||||
async def __call__(self, scope, receive, send):
|
async def __call__(self, scope, receive, send):
|
||||||
if scope.get("type") == "lifespan":
|
if scope.get("type") == "lifespan":
|
||||||
|
@ -245,7 +245,7 @@ class TracingMiddleware:
|
||||||
path = scope.get("path", "")
|
path = scope.get("path", "")
|
||||||
|
|
||||||
# Check if the path is a FastAPI built-in path
|
# Check if the path is a FastAPI built-in path
|
||||||
if any(path.startswith(fastapi_path) for fastapi_path in self.fastapi_paths):
|
if path.startswith(self.fastapi_paths):
|
||||||
# Pass through to FastAPI's built-in handlers
|
# Pass through to FastAPI's built-in handlers
|
||||||
logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}")
|
logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}")
|
||||||
return await self.app(scope, receive, send)
|
return await self.app(scope, receive, send)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue