Skip to content

Commit

Permalink
Create a Butler to handle each request
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirving committed May 8, 2024
1 parent 63b3326 commit 8517bc1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/butlerexampleservice/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@
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(
tract: int,
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}"


Expand Down

0 comments on commit 8517bc1

Please sign in to comment.