Programmation de carrelage dynamique
# Add private COG endpoints requiring token validation
from fastapi import APIRouter, Depends, HTTPException, Security
from fastapi.security.api_key import APIKeyQuery
from titiler.application.main import app
from titiler.core.factory import TilerFactory
api_key_query = APIKeyQuery(name="access_token", auto_error=False)
def token_validation(access_token: str = Security(api_key_query)):
"""stupid token validation."""
if not access_token:
raise HTTPException(status_code=403, detail="Missing `access_token`")
if not access_token == "token":
raise HTTPException(status_code=403, detail="Invalid `access_token`")
return True
# Custom router with token dependency
router = APIRouter(dependencies=[Depends(token_validation)])
tiler = TilerFactory(router_prefix="private/cog", router=router)
app.include_router(tiler.router, prefix="/private/cog", tags=["Private"])
Mohamed Samir