mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +00:00
chore: return webmethod from find_matching_route (#2883)
This will be used to support API access control, i.e. Webmethod would have a `required_scope` attribute, and we need access to that in the middleware.
This commit is contained in:
parent
1463b79218
commit
cbe89d2bdd
4 changed files with 29 additions and 21 deletions
|
@ -304,7 +304,9 @@ class TracingMiddleware:
|
|||
self.route_impls = initialize_route_impls(self.impls)
|
||||
|
||||
try:
|
||||
_, _, trace_path = find_matching_route(scope.get("method", hdrs.METH_GET), path, self.route_impls)
|
||||
_, _, route_path, webmethod = find_matching_route(
|
||||
scope.get("method", hdrs.METH_GET), path, self.route_impls
|
||||
)
|
||||
except ValueError:
|
||||
# If no matching endpoint is found, pass through to FastAPI
|
||||
logger.debug(f"No matching route found for path: {path}, falling back to FastAPI")
|
||||
|
@ -321,6 +323,7 @@ class TracingMiddleware:
|
|||
if tracestate:
|
||||
trace_attributes["tracestate"] = tracestate
|
||||
|
||||
trace_path = webmethod.descriptive_name or route_path
|
||||
trace_context = await start_trace(trace_path, trace_attributes)
|
||||
|
||||
async def send_with_trace_id(message):
|
||||
|
@ -504,7 +507,7 @@ def main(args: argparse.Namespace | None = None):
|
|||
routes = all_routes[api]
|
||||
impl = impls[api]
|
||||
|
||||
for route in routes:
|
||||
for route, _ in routes:
|
||||
if not hasattr(impl, route.name):
|
||||
# ideally this should be a typing violation already
|
||||
raise ValueError(f"Could not find method {route.name} on {impl}!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue