MCPcopy Create free account
hub / github.com/encode/starlette / CountingRoute

Class CountingRoute

tests/middleware/test_opentelemetry.py:287–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285 _, exporter = tracer_provider
286
287 class CountingRoute(Route):
288 match_count = 0
289
290 def matches(self, scope: Scope) -> tuple[Match, Scope]:
291 self.match_count += 1
292 return super().matches(scope)
293
294 route = CountingRoute("/users/{username}", homepage)
295 app = Starlette(routes=[route], middleware=[Middleware(OpenTelemetryMiddleware)])

Calls

no outgoing calls