From a9fc0c559f5c8a8e92b2c01178dbed35c2d274aa Mon Sep 17 00:00:00 2001 From: pajowu Date: Mon, 20 Nov 2023 09:23:24 +0100 Subject: [PATCH] Relax type of get_route_name argument to HttpConnection All information required is already provided by the HttpConnection class, which Request is a subclass of. Changing this to HttpConnection allows also passing a WebSocket instead --- src/prometheus_fastapi_instrumentator/routing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/prometheus_fastapi_instrumentator/routing.py b/src/prometheus_fastapi_instrumentator/routing.py index 2c714d3..0725c0a 100644 --- a/src/prometheus_fastapi_instrumentator/routing.py +++ b/src/prometheus_fastapi_instrumentator/routing.py @@ -39,7 +39,7 @@ from typing import List, Optional -from starlette.requests import Request +from starlette.requests import HttpConnection from starlette.routing import Match, Mount, Route from starlette.types import Scope @@ -66,7 +66,7 @@ def _get_route_name( return None -def get_route_name(request: Request) -> Optional[str]: +def get_route_name(request: HttpConnection) -> Optional[str]: """Gets route name for given request taking mounts into account.""" app = request.app