From 8517bc169acc42cedecccd3022da56b2ce96d822 Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Wed, 8 May 2024 14:38:36 -0700 Subject: [PATCH] Create a Butler to handle each request --- src/butlerexampleservice/handlers/external.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/butlerexampleservice/handlers/external.py b/src/butlerexampleservice/handlers/external.py index 51d83a1..e63a183 100644 --- a/src/butlerexampleservice/handlers/external.py +++ b/src/butlerexampleservice/handlers/external.py @@ -15,8 +15,12 @@ external_router = APIRouter() """FastAPI router for all external handlers.""" +from lsst.daf.butler import LabeledButlerFactory from safir.dependencies.gafaelfawr import auth_delegated_token_dependency +_BUTLER_FACTORY = LabeledButlerFactory() +_BUTLER_REPOSITORY = "dp02" + @external_router.get("/coadd_url") def get_coadd_url( @@ -24,6 +28,10 @@ def get_coadd_url( patch: int, delegated_token: Annotated[str, Depends(auth_delegated_token_dependency)], ) -> str: + butler = _BUTLER_FACTORY.create_butler( + label=_BUTLER_REPOSITORY, access_token=delegated_token + ) + return f"http://stub.example/{tract}/{patch}"